Socket
Socket
Sign inDemoInstall

monastery-js

Package Overview
Dependencies
76
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    monastery-js

⛪ A straight forward MongoDB ODM built around Monk


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
86.3 MB
Created
Weekly downloads
 

Readme

Source

NPM Build Status

Features

  • User friendly API design, built around the awesome Monk
  • Simple CRUD operations with model population
  • Model validation deriving from your schema
  • Custom error messages can be defined in your schema
  • Normalised error responses ready for client consumption
  • Automatic mongodb index setup

Install

This repository is distributed with NPM. After installing NPM, you can install Monastery via:

$ npm install --save monastery-js

Usage

// Initialise a monastery manager
const db = require('monastery-js')('localhost/mydb')
// const db = require('monastery-js')('user:pass@localhost:port/mydb')

// Define a model
db.model('user', {
  fields: {
    name: { type: 'string' },
    pets: [{ type: 'string' }],
    address: { city: { type: 'string', minLength: 10 } },
    points: [[{ type: 'number' }]]
  }
})

// Insert some data
db.user.insert({
  data: {
    name: 'Martin Luther',
    pets: ['sparky', 'tiny'],
    address: { city: 'Eisleben' },
    points: [[1, 5], [3, 1]]
  }

}).then(data => {
  // valid data..

}).catch(errs => {
  // [{
  //   detail: "Value needs to be at least 10 characters long.",
  //   status: "400",
  //   title: "address.city",
  //   meta: {
  //     field: "city",
  //     model: "user",
  //     rule: "minLength"
  //   }
  // }]
})

Debugging

This package uses Debug which allows you to see different levels of output:

$ DEBUG=monastery:info
# or show all levels of output, currently shows the same output as above
$ DEBUG=monastery:*

Contributing

Coming soon...

License

Copyright 2020 Ricky Boyce. Code released under the MIT license.

Keywords

FAQs

Last updated on 13 Jan 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc