# clientside-model-manager

> sequelize and mongoose style object-modeling database-interface for the browser

Latest version **1.1.1** (published 2018-03-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install clientside-model-manager
pnpm add clientside-model-manager
yarn add clientside-model-manager
bun add clientside-model-manager
```

## 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.1.1 |
| Published | 2018-03-23 |
| First published | 2018-03-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 50.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | uladkasach |
| Maintainers | uladkasach |
| Keywords | clientside |

## Links

- npm: https://www.npmjs.com/package/clientside-model-manager
- Repository: https://github.com/uladkasach/clientside-model-manager
- Homepage: https://github.com/uladkasach/clientside-model-manager#readme
- Issues: https://github.com/uladkasach/clientside-model-manager/issues
- npm.io page: https://npm.io/package/clientside-model-manager

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2018-03-23
- 1.0.0 — 2018-03-23

## README

# clientside-model-manager


# Basic Usage
### 1. define your models
```js
var Backtest = function(object){
    Object.assign(this, object); // when we retrieve an object from the database, append its values to this object
}
Backtest.prototype = {
    find : async function(options){
        // validate the options
        var [valid, error] = this.validate_find_options(options);
        if(valid !== true) throw error;

        // pass request to server
        var database_object = await api.get("/models/find/backtest", options); // let the server handle interpreting and validating the where string

        // cast server response to backtest objects
        var casted_object =  new this.constructor(database_object); // same as `new Backtest(database_object)``

        // return the data
        return data;
    },
}
```

### 2. initialize the model manager
```js
var active_models = {
    "Plan" : "/_models/plan.js",
    "Funding" : "/_models/funding.js",
    "Backtest" : {path:"/_models/backtest.js", preload:true}
}
var models = new Model_Manager(active_models)
module.exports = models;
```

### 3. use the models - like you would with sequelize or mongodb
```js
var models = await require("path/to/models")
models.Backtest.find({
    where : {
        Parent : parent.type,
        ParentId : parent.id,
    }
})
```

# Caching
Since making requests to the database is expensive from the client, the module manager comes with the ability to cache data. The only thing a developer must keep in mind while using the caching functionality is that the developer will need to manually trigger data_pulls from the database to ensure that data is up to date.
- note, automatic timed updates will be availible in future - but this will still not resolve this problem entirely

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