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

cosa

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cosa

Cosa Models for MongoDB

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
60
decreased by-67.74%
Maintainers
1
Weekly downloads
 
Created
Source

Cosa

Build Status npm version

Simplified object modeling for MongoDB

Installation

Use your favorite package manager to add cosa to your project.

$ yarn add cosa

Usage

First define a model:

const { Model } = require('cosa');

const UserModel = Model.define({
  name: 'UserModel',
  collection: 'users',
  properties: {
    name: { type: 'string', required: true },
    email: { type: 'string', required: true, email: true }
  }
})

Use the model to add users to the database:

const newUser = UserModel.create({ 
  name: 'John Smith',
  email: 'jsmith@example.com'
})
newUser.save()

Fetch all the users in the database:

UserModel
  .find({}, { array: true })
  .then((users) => {
    // loop over the array of users and do something
  })

Reference

License

The module is available as open source under the terms of the MIT License.

FAQs

Package last updated on 12 Oct 2018

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