background preloader

Modules pour nodeJS

Facebook Twitter

Koa-request. Connection URI. The URL format is unified across official drivers from Mongodb with some options not supported on some drivers due to implementation differences.

Connection URI

The ones not supported by the Node.js driver are left out for simplicities sake. Basic parts of the url is a required prefix to identify that this is a string in the standard connection format.username:password@ is optional. If given, the driver will attempt to login to a database after connecting to a database server.host1 is the only required part of the URI.

It identifies either a hostname, IP address, or unix domain socket:portX is optional and defaults to :27017 if not provided. Replica set configuration: replicaSet=name The driver verifies that the name of the replica set it connects to matches this name. Connection Configuration: Connection pool configuration: maxPoolSize=n: The maximum number of connections in the connection pool Default value is 5 Write concern configuration: More detailed information about write concerns can be found at. Index. Koa-mongo. Mongodb. !

mongodb

[Gitter]( Chat.svg) The MongoDB driver is the high level part of the 2.0 or higher MongoDB driver and is meant for end users. MongoDB Node.JS Driver Blogs of Engineers involved in the driver Christian Kvalheim @christkv Bugs / Feature Requests Think you’ve found a bug? Create an account and login to the NODE project Create Issue - Please provide as much information as possible about the issue type and how to reproduce it. Bug reports in JIRA for all driver projects (i.e. Questions and Bug Reports mailing list: Change Log The quick start guide will show you how to setup a simple application using node.js and MongoDB. Create the package.json file Let's create a directory where our application will live. Mkdir myproject cd myproject Enter the following command and answer the questions to create the initial structure for your new project npm init Next we need to edit the generated package.json file to add the dependency for the MongoDB driver.

"name": "myproject", "version": "1.0.0", "main": "index.js", Mongoose. Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

mongoose

Documentation mongoosejs.com Support Plugins Check out the plugins search site to see hundreds of related modules from the community. Build your own Mongoose plugin through generator-mongoose-plugin. Contributors View all 100+ contributors. Live Examples Installation First install node.js and mongodb. . $ npm install mongoose Stability The current stable branch is master. Overview Connecting to MongoDB First, we need to define a connection. Both connect and createConnection take a URI, or the parameters host, database, port, options. var mongoose = require'mongoose'; mongooseconnect' Once connected, the open event is fired on the Connection instance. Note: If the local connection fails then try using 127.0.0.1 instead of localhost. Important! Defining a Model Models are defined through the Schema interface. var Schema = mongooseSchema ObjectId = SchemaObjectId; var BlogPost =

Mongoose vs mongoDb native. Holy crap.

mongoose vs mongoDb native

MongoDB native drivers are SO much faster than updates through mongoose’s ORM. Initially, when I set out on this quest to enhance mongoDB performance with node.js, I thought that modifying my queries and limiting the number of results returned would be sufficient to scale. I was wrong (thanks Bush for the imagery). It turns out that the overhead that mongoose adds for wrapping mongoDB documents within mongoose’s ORM is tremendous. Well, I should say tremendous for our use case. In my previous two posts of tweaking mongoDB / mongoose for performance enhancements (Part 1 and Part 2), I discussed optimization of queries or making simple writes instead of reads. Example #1: ~400 streams, insertion times. Ns total read write streams 193ms 0ms 193ms packets 30ms 1ms 29ms devices 9ms 9ms 0ms Example 2: ~1000 streams, insertion times.

Ns total read write packets 186ms 169ms 17ms devices 161ms 159ms 2ms streams 97ms 21ms 76ms Here’s what the new improvements look like: Like this: Mongoose ODM v4.1.1.