Production Level Knowledge & Tips

  1. 未分類
  2. 10 view

[mongoose][mongoDB]How to select collection

Select collection at “lower case of collection_name+s” part below. Note that you have to add “s” at last end use lower case of collection name.
var EventRelation, db, mongoose;
mongoose = require('mongoose');
db = mongoose.connect('mongodb://localhost/db_name',
	function(err) {
		if (err) {
			console.log(err);
		} else {
			console.log('Connection Success!');
		}
	}
);

DBSchema = new mongoose.Schema({
  id                   : Number,
  update_time          : Date
});

exports.testDB = db.model('lower case of collection_name+s', DBSchema);

未分類 recent post

  1. Install sbt 1.0.0 and run sample template

  2. Visualization of Neural Network and its Train…

  3. [Machine Learning]Created docker image includ…

  4. [Node.js]How to write batch script with Node.…

  5. [Hive]Get top n items for each category

関連記事

PAGE TOP