background preloader

Mongoose ODM

Mongoose ODM
Related:  Node.Js ResourcesModules pour nodeJS

Packages/1.0 - CommonJS Spec Wiki Implementations JSBuild, PINF JS Loader, ArangoDB Packages This specification describes the CommonJS package format for distributing CommonJS programs and libraries. A CommonJS package is a cohesive wrapping of a collection of modules, code and other assets into a single form. It provides the basis for convenient delivery, installation and management of CommonJS components. This specifies the CommonJS package descriptor file and package file format. Package Descriptor File Each package must provide a top-level package descriptor, "package.json". Required Fields Each package must provide all the following fields in its package descriptor file: name the name of the package. description a brief description of the package. version a version string conforming to the Semantic Versioning requirements ( keywords an Array of string keywords to assist users searching for the package in catalogs. maintainers Array of maintainers of the package. contributors bugs URL for submitting bugs. "os"

express - MongoDB schema design for multible auth user accounts Express - node web framework Getting started With node installed (download), get your first application started by creating a directory somewhere on your machine: $ mkdir hello-world In this same directory you'll be defining the application "package", which are no different than any other node package. You'll need a package.json file in the directory, with express defined as a dependency. Now that you have a package.json file in this directory you can use npm(1) to install the dependencies, in this case just Express: $ npm install Once npm finishes you'll have a localized Express 3.x dependency in the . $ npm ls hello-world@0.0.1 /private/tmp └─┬ express@3.0.0beta7 ├── commander@0.6.1 ├─┬ connect@2.3.9 │ ├── bytes@0.1.0 │ ├── cookie@0.0.4 │ ├── crc@0.2.0 │ ├── formidable@1.0.11 │ └── qs@0.4.2 ├── cookie@0.0.3 ├── debug@0.7.0 ├── fresh@0.1.0 ├── methods@0.0.1 ├── mkdirp@0.3.3 ├── range-parser@0.0.4 ├─┬ response-send@0.0.1 │ └── crc@0.2.0 └─┬ send@0.0.3 └── mime@1.2.6 Now to create the application itself! Then fire it up!

Meteor Connection URI The URL format is unified across official drivers from Mongodb with some options not supported on some drivers due to implementation differences. 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. Replica set configuration: replicaSet=name The driver verifies that the name of the replica set it connects to matches this name. Connection Configuration: ssl=true|false|prefer true: the driver initiates each connections with SSLfalse: the driver initiates each connection without SSLprefer: the driver tries to initiate each connection with SSL, and falls back to without SSL if it fails.Default value is false. connectTimeoutMS=ms How long a connection can take to be opened before timing out.Current driver behavior already differs on this, so the default must be left to each driver.

Felix's Node.js Style Guide/en « Home / All Guides IMPORTANT: This version is outdated, the latest version is available on GitHub. There is no official document that governs the style of node.js applications. This guide is my opinionated attempt to bring you a good set of instructions that will allow you to create beautiful and consistent software. This guide assumes that you are only targeting node.js. Please also note that node.js, as well as various packages for it, have their own slightly different styles. Tabs vs Spaces Let's start with the religious problems first. Semicolons There are rebellious forces that try to steal your semicolons from you. Editors You can use any editor. I'm typing this document in Notes on my iPad, but that's because I'm on a beach in Thailand. Trailing whitespace Just like you brush your teeth after every meal, you clean up any trailing whitespace in your JavaScript files before committing. Line length Limit your lines to 80 characters. Quotes Use single quotes, unless you are writing JSON.

Essential Node.js patterns and snippets In this post, I take a look at the different patterns that you need to know when using Node.js. These came from my own coding and from a look at the code behind Tim Caswell’s flow control libraries. I think it is necessary to know how these basic patterns are implemented even if you use a library.. 1.1 Class pattern If the class is long, then instead of doing a single Class.prototype = {…} assignment, it may be split into multiple Class.prototype.method = function () {..} assignments. Reminder: Assign all your properties some value in your constructor. 1.2 Accessing global values from objects // constructorvar Class = function(global, value2) { this.global = global;}// access using this.global in class methods 1.3 Factory pattern // Constructorvar Class = function(value1, value2) { ... }// FactoryClass.factory(value1) { return new Class(value1, "aaa"); }// properties and methodsClass.prototype = { ... }; 1.4 Sharing state between modules 1.5 Singleton class (added Feb 2011) 2.1 Parsing GET 4.

The Node Beginner Book CoffeeScript mongoose Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. 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; body : String

Related: