Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

cosa

Package Overview
Dependencies
9
Maintainers
3
Versions
64
Issues
File Explorer

Advanced tools

cosa

Cosa Models for MongoDB

    7.0.0latest
    GitHub

Version published
Maintainers
3
Weekly downloads
230
decreased by-73.62%

Weekly downloads

Readme

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

Last updated on 23 Feb 2023

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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