Giter Club home page Giter Club logo

rapid-simple-mongo's Introduction

#rapid-simple-mongo

simple to use the mongodb

##What is this? 用于rapid框架的mongodb插件, 由于在公共集群中的持久链接会造成集群资源的额外开销,多数公共数据库都有连接数及空闲时间限制,所以在直接使用mongodb driver并复用db对像时driver的自动重连逻辑稳定性较差(特别是在需要认证的情况下.),基于以上情况,这里提供一个简易包装处理.以短链方式操作db,用于完成一般性的数据操作任务,只提供常用的find,findOne,insert,remove,update,save,count等几个方法. ##API

###simpleMongo.getAgent(dburl,opts); 创建一个由dburl指定的db的连接对像. 返回ClientAgent

dburl {string} mongodb的connect string. 具体请参照 MongoDB Connection URI.

opts {object} 配置信息, 基于MongoClient.connect(dbur,opts)的opts对像.具有connect的opts的全部属性,并增加用于限制空闲时间的idle属性,单位为毫秒.默认为30秒

###simpleMongo.connect(dburl,cb); 将直接调用原始的 mongoClient.connect(dburl,cb);

###simpleMongo.getMongodb(); 直接返回require("mongodb")的原始对像.

###ClientAgent 查询对像,具有以下几个一般查询方法. ####ClientAgent.find(collectionName,selector,[opts],callback); ####ClientAgent.findOne(collectionName,selector,[opts],callback); ####ClientAgent.insert(collectionName,docs,[opts],callback); ####ClientAgent.update(collectionName,selector,[opts],opts,callback); ####ClientAgent.remove(collectionName,selector,[opts],callback); ####ClientAgent.save(collectionName,doc,[opts],callback); ####ClientAgent.count(collectionName,doc,[opts],callback);

rapid-simple-mongo's People

Contributors

huang-xin avatar wang-su avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.