Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yeliex/node.mongo
封装后的node mongo library
https://github.com/yeliex/node.mongo
Last synced: about 2 months ago
JSON representation
封装后的node mongo library
- Host: GitHub
- URL: https://github.com/yeliex/node.mongo
- Owner: yeliex
- License: mit
- Created: 2016-03-18T09:03:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T00:14:46.000Z (over 3 years ago)
- Last Synced: 2024-11-15T07:44:09.826Z (about 2 months ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node.mongo
[![npm](https://img.shields.io/npm/v/node.mongo.svg?style=flat-square)](https://www.npmjs.com/package/node.mongo)
node mongo library
## Installation
```
$ npm install node.mongo
```## Usage
```js
const mongo = require("node.mongo")(url, {
timestamp: true, // auto add createdTime and updatedTime
createdTime: 'createdTime', // customer createdTime field (timestamp=true)
updatedTime: 'updatedTime' // customer createdTime field (timestamp=true)
});const res = await mongo.findOne(collection,condition);
```## Example
```js
const mongo = require("node.mongo")("mongodb://localhost/test");const query = await mongo.findOne("test",{});
```## API Methods
- collections
- *return all collections in db*
- collection(name)
- *return specified collection (for other methods not defined)*
- count(collection,query,options)
- *return number of result in specified collection*
- insert(collection,data)
- *insert a series of new item*
- update(collection,filter,data,options)
- *upsert many items*
- updateOne(collection,filter,data,options)
- *upsert a new item (auto upsert)*
- find(collection,filter,condition,cursor)
- *return a group of items (array) (cursor = false)*
- *return a MongoCursor object (object) (cursor = true)*
- findOne(collectionName,filter,condition)
- *return first item accord with filter*
- femove(collectionName,filter,option)
- *remove any numbers of document*
- aggregate(collectionName,pipeline, options)
- *Execute an aggregation framework pipeline against the collection*