All Projects → brickyang → Egg Mongo Native

brickyang / Egg Mongo Native

Licence: mit
MongoDB egg.js plugin using native driver.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Egg Mongo Native

Qmgo
Qmgo - The Go driver for MongoDB. It‘s based on official mongo-go-driver but easier to use like Mgo.
Stars: ✭ 444 (+543.48%)
Mutual labels:  mongodb-driver, mongodb
Mongo Rust Driver
The official MongoDB Rust Driver
Stars: ✭ 633 (+817.39%)
Mutual labels:  mongodb-driver, mongodb
Egg 24time
A Twitter-like news and social server for Egg. 微信小程序社区全栈解决方案
Stars: ✭ 493 (+614.49%)
Mutual labels:  eggjs, egg-plugin
Doracms
DoraCMS是基于Nodejs+eggjs+mongodb编写的一套内容管理系统,结构简单,较目前一些开源的cms,doracms易于拓展,特别适合前端开发工程师做二次开发。
Stars: ✭ 3,180 (+4508.7%)
Mutual labels:  mongodb, eggjs
Phalcon Mongodb Odm
MongoDB ODM for Phalcon framework for new mongodb php extension with query builder and rich functionality
Stars: ✭ 42 (-39.13%)
Mutual labels:  mongodb-driver, mongodb
Egg Graphql
Stars: ✭ 345 (+400%)
Mutual labels:  eggjs, egg-plugin
Mongokitten
Native MongoDB driver for Swift, written in Swift
Stars: ✭ 605 (+776.81%)
Mutual labels:  mongodb-driver, mongodb
egg-sentry
Sentry Plugin For Egg.js
Stars: ✭ 18 (-73.91%)
Mutual labels:  egg-plugin, eggjs
Antvueblogfront
🔥使用Vue全家桶 + Egg + Mongodb 写的个人网站博客。使用docker compose 一键部署。(最近比较忙,部署还有点问题,后期补上)
Stars: ✭ 36 (-47.83%)
Mutual labels:  mongodb, eggjs
Mongo Cxx Driver
C++ Driver for MongoDB
Stars: ✭ 792 (+1047.83%)
Mutual labels:  mongodb-driver, mongodb
egg-logger-sls
Logger transport for aliyun sls.
Stars: ✭ 14 (-79.71%)
Mutual labels:  egg-plugin, eggjs
Egg Cancan
cancancan like authorization plugin for Egg.js
Stars: ✭ 47 (-31.88%)
Mutual labels:  eggjs, egg-plugin
egg-parameters
Merge all parameters (ctx.params, ctx.request.query, ctx.request.body) into ctx.params like Rails application.
Stars: ✭ 24 (-65.22%)
Mutual labels:  egg-plugin, eggjs
Egg Mongoose
Stars: ✭ 386 (+459.42%)
Mutual labels:  mongodb, egg-plugin
egg-cache
💾 Cache plugin for eggjs
Stars: ✭ 60 (-13.04%)
Mutual labels:  egg-plugin, eggjs
Egg Restfulapi
🏅 基于Egg.js 2.0 & {mongoose,jwt}RESTful API 模板,用于快速集成开发RESTful前后端分离的服务端。
Stars: ✭ 524 (+659.42%)
Mutual labels:  mongodb, egg-plugin
Mongo Swift Driver
The official MongoDB driver for Swift
Stars: ✭ 242 (+250.72%)
Mutual labels:  mongodb-driver, mongodb
egg-rbac
Role Based Access Control for eggjs
Stars: ✭ 32 (-53.62%)
Mutual labels:  egg-plugin, eggjs
Mongo Php Driver
MongoDB PHP driver
Stars: ✭ 737 (+968.12%)
Mutual labels:  mongodb-driver, mongodb
Mongoc.jl
MongoDB driver for the Julia Language
Stars: ✭ 46 (-33.33%)
Mutual labels:  mongodb-driver, mongodb

NPM version NPM quality build status Test coverage David deps Known Vulnerabilities npm download

中文版

Users who don't use Egg.js could use easy-mongodb.

This plugin base on node-mongodb-native, provides the official MongoDB native driver and APIs.

It wraps some frequently-used API to make it easy to use but keep all properties as it is. For example, to find a document you need this with official API

db.collection('name')
  .find(query, options)
  .skip(skip)
  .limit(limit)
  .project(project)
  .sort(sort)
  .toArray();

and with this plugin

app.mongo.find('name', { query, skip, limit, project, sort, options });

Install

$ npm i egg-mongo-native --save

Enable Plugin

// {app_root}/config/plugin.js
exports.mongo = {
  enable: true,
  package: 'egg-mongo-native',
};

Configuration

Single Instance

// {app_root}/config/config.default.js
exports.mongo = {
  client: {
    host: 'host',
    port: 'port',
    name: 'test',
    user: 'user',
    password: 'password',
    options: {},
  },
};

Replica Set (v2.1.0 or higher)

// mongodb://host1:port1,host2:port2/name?replicaSet=test
exports.mongo = {
  client: {
    host: 'host1,host2',
    port: 'port1,port2',
    name: 'name',
    options: {
      replicaSet: 'test',
    },
  },
};

// mongodb://host:port1,host:port2/name?replicaSet=test
exports.mongo = {
  client: {
    host: 'host', // or ['host']
    port: 'port1,port2', // or ['port1', 'port2']
    name: 'name',
    options: {
      replicaSet: 'test',
    },
  },
};

Multiple Instances

Can not set client and clients both.

// {app_root}/config/config.default.js
exports.mongo = {
  clients: {
    db1: {
      host: 'host',
      port: 'port',
      name: 'db1',
      user: 'user',
      password: 'password',
      options: {},
    },
    db2: {
      host: 'host',
      port: 'port',
      name: 'db2',
      user: 'user',
      password: 'password',
      options: {},
    },
  },
};

see config/config.default.js for more detail.

Example

The APIs provided by plugin usually need two arguments. The first is commonly the collection name, and the second is an object keeps the arguments of official API. For example, to insert one document using official API

db.collection('name').insertOne(doc, options);

and using plugin API

const args = { doc, options };
app.mongo.insertOne('name', args);

For Multiple Instances

const args = { doc, options };
app.mongo.get('db1').insertOne('name', args);

The args is an object provides the arguments to official API.

Please read easy-mongodb for all APIs(tansaction is now supported) and more examples.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].