Weekly downloads
Readme
Simplified object modeling for MongoDB
Use your favorite package manager to add cosa to your project.
yarn add cosa
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
})
The module is available as open source under the terms of the MIT License.
FAQs
Cosa Models for MongoDB
The npm package cosa receives a total of 134 weekly downloads. As such, cosa popularity was classified as not popular.
We found that cosa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
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.