# replit-db-orm

> A quick ORM for repl's key/value database. Inspired by Mongoose.

Latest version **1.0.1** (published 2021-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install replit-db-orm
pnpm add replit-db-orm
yarn add replit-db-orm
bun add replit-db-orm
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-02-09 |
| First published | 2021-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Garrett Allen |
| Maintainers | garrett_makes |
| Keywords | orm, repl, mongoose |

## Links

- npm: https://www.npmjs.com/package/replit-db-orm
- Repository: https://github.com/adrenallen/replit-db-orm
- Homepage: https://github.com/adrenallen/replit-db-orm#readme
- Issues: https://github.com/adrenallen/replit-db-orm/issues
- npm.io page: https://npm.io/package/replit-db-orm

## Dependencies (1)

- [@replit/database](https://npm.io/package/@replit/database.md) ^2.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-02-09
- 1.0.0 — 2021-02-09

## README

# Replit DB ORM

A quick experiment to build an ORM on top of [Repl.it](https://repl.it)'s existing key/value based database.

[More information about Repl's database can be found here](https://docs.repl.it/misc/database)

## Usage

```
const {model, Schema} = require('replit-db-orm');

// Define a schema, what fields we want and their types
var testSchema = {
  Property1: Number,
  Words: String
};

// Create the model, specify the name and can specify the "table"
// as a third param which is just how we store the keys
const testModel = model("test", testSchema);


(async () => {
  // Create a new object by our model
  let a = new testModel({Property1: 55, Words: "Test test"});

  // save it to the db
  await a.save()

  // Find matches!
  testModel.find({Property1: 55}).then(console.log);
})();

```

## How it works
Each model property is saved as a key/value based on the schema definition.

Since we know the first part of the keys, we can query by rough matches to find models of a certain type with matching property values.

Then we can pull the model id out of the key itself with some simple regex.


## Contributing
Feel free to open PRs to improve this, it's still missing quite a few key features for usage such as delete, findOne, or a way to add other where clauses like OR.

---
_Source: https://npm.io/package/replit-db-orm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
