Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

node-sap-mongo

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-sap-mongo

SAP MongoDB connectivity layer

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
2
Created
Source

Build Version Dependency Status devDependency Status Coverage node-sap-mongo

MongoDB connectivity layer

##Using the Common MongoDB Connection

###Initializing the connection This must be done once by the main server process. This is done by the Norman AppServer, you may do this manually in your service tests.

commonServer.db.connection.initialize({ database: "norman-test" }, function (err)  {
  if (err) {
    console.error("Oops, no magic today!");
  }
});

Optional second parameter allows configuring the deployment strategy. Default strategy "single" stores all Norman collection into a single database. Production strategy "distribute" spreads the collections over multiple domain databases to reduce write contention. Database distribution may be fine-tuned with the "map" strategy.

###Getting a mongoose connection The following code snippet returns a connection to the database configured for the module "my-module" according to the deployment strategy.

var connection = commonserver.db.connection.getMongooseConnection("my-module");

###Getting a Mongo database connection

var db1 = commonserver.db.connection.getDb("my-module");
var db2 = commonserver.db.connection.getMongooseConnection("my-other-module").db;

###Creating mongoose models We offer a simple way to define mongoose model on a specific connection :

var commonServer = require('norman-common-server'),
    mongoose = commonServer.db.mongoose;

var MySchema = mongoose.createSchema('my-module', { ... });


module.exports = mongoose.createModel('MyModel', MySchema);

FAQs

Package last updated on 18 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts