droopy-mongo
Wrapper for native mongodb driver to return promises.
npm install droopy-mongo
// Initializevar mongo = ;var dao = configmongourl;var topics = dao; // Utilizetopics;
Methods
Collection
collection.find(query)
-collection.find(query, fields)
- fields param limit the fields to returncollection.find(query, fields, options)
- options let you specify things like sorting and limitscollection.findOne(query)
- returns a single objectcollection.checkIfExists(query)
- returns true if the query has at least one resultcollection.insert(item)
- item can be either a single object or an array of objects (for a batch insert)collection.update(query, updates)
- peforms a merge, only updates properties specified in theupdates
param.collection.updateOne(query, updates)
- performs a merge on the first item that matches the querycollection.overwrite(query, item)
- overwrites all matching documents with the passed in itemcollection.remove(query)
- deletes all items that match the query
//EXAMPLESvar mongo = ;var dao = configmongourl;var topics = dao; topics; topics; topics; topics; topics;