Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Mongoose and multiple database in single node.js project

var conn      = mongoose.createConnection('mongodb://localhost/testA');
var conn2     = mongoose.createConnection('mongodb://localhost/testB');

// stored in 'testA' database
var ModelA    = conn.model('Model', new mongoose.Schema({
  title : { type : String, default : 'model in testA database' }
}));

// stored in 'testB' database
var ModelB    = conn2.model('Model', new mongoose.Schema({
  title : { type : String, default : 'model in testB database' }
}));
Comment

PREVIOUS NEXT
Code Example
Javascript :: popper.js and jquery 
Javascript :: recharts change scale 
Javascript :: mongodb aggregate project 
Javascript :: javascript print to pdf 
Javascript :: react native docs 
Javascript :: redux reducer 
Javascript :: set exit node tor 
Javascript :: --resolveJsonModule 
Javascript :: intersection observer api 
Javascript :: javascript remove last item 
Javascript :: attributes in same line prettier 
Javascript :: javascript timestamp conversion 
Javascript :: array any 
Javascript :: md 5 npm 
Javascript :: json data types 
Javascript :: gltfjsx 
Javascript :: submit form with ajax 
Javascript :: es6 javascript 
Javascript :: Uncaught ReferenceError: am4core is not defined 
Javascript :: angular pass async pipe value to funciton 
Javascript :: add onclick javascript dynamically 
Javascript :: jquery find and replace text 
Javascript :: numero random en js 
Javascript :: how to mock a library in jest 
Javascript :: get url 
Javascript :: head component nextjs 
Javascript :: flatlist only rendering 10 items 
Javascript :: jest mock method by name 
Javascript :: route not getting refresh with different id in angular 
Javascript :: points in three js 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =