Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monastery-js

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monastery-js

⛪ A straight forward MongoDB ODM built around Monk

  • 1.10.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 13 Jan 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc