Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // port to use mongodb
- var port = 3500;
- var path = require('path');
- var nodePath = path.normalize(process.execPath + '/../../lib/node_modules');
- var mongoose = require(path.join(nodePath, 'mongoose'));
- mongoose.connect('mongodb://localhost:' + port + '/app');
- console.log('XXX');
- var User = new mongoose.Schema({
- name: String,
- pass: String,
- title: String
- });
- var userModel = mongoose.model('User', User);
- var News = new mongoose.Schema({
- author: mongoose.Schema.ObjectId,
- content: String
- });
- var newsModel = mongoose.model('News', News);
- function createDummyData() {
- u = new userModel({name: 'Harry'});
- u.save();
- }
- // createDummyData();
- console.log('queries');
- userModel.find({name: 'Harry'}, function(err, d){
- console.log(d.length, d, err);
- });
- mongoose.disconnect();
Add Comment
Please, Sign In to add comment