# mongo-model-vpj

> Model based database for mongodb

Latest version **0.0.3** (published 2014-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongo-model-vpj
pnpm add mongo-model-vpj
yarn add mongo-model-vpj
bun add mongo-model-vpj
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2014-08-12 |
| First published | 2014-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Varuna Jayasiri |
| Maintainers | vpj |
| Keywords | mongodb, database |

## Links

- npm: https://www.npmjs.com/package/mongo-model-vpj
- Repository: https://github.com/vpj/mongo-model
- Issues: https://github.com/vpj/mongo-model/issues
- npm.io page: https://npm.io/package/mongo-model-vpj

## Dependencies (2)

- [bson](https://npm.io/package/bson.md) >=0
- [mongodb](https://npm.io/package/mongodb.md) >=0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2014-08-12
- 0.0.2 — 2014-08-11
- 0.0.1 — 2014-08-11

## README

#Mongodb wrapper

##Installation

    npm install mongo-model

##[Documentation](http://vpj.github.io/mongo-model/)

##[Example.coffee](http://vpj.github.io/mongo-model/example.html)

A basic database model

```coffee
class Fruit extends mongodb.Model
 model: 'Fruit'

 @defaults
  handle: ''
  name: ''
  price: 0.00
  description: ''
  images: []

models =
 Fruit: Fruit
```

Initialize database

```coffee
db = new mongodb.Database 'testdata', models
```

Load all objects of model *Fruit*

```coffee
load = ->
 db.load 'Fruit', {}, (err, objs) ->
  obj = objs[0]
  console.log obj.handle
  obj.handle = 'test'
  console.log obj.handle
  console.log err, obj
```

Save an object

```coffee
save = (callback) ->
 f = new Fruit {name: 'Apple', handle: 'apple'}, db: db
 f.save callback
```

```coffee
db.setup ->
 save ->
  console.log "saved"
  load()
```

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