var mongoose = require('../lib/mongooseConnect');
- запрашивает такой файл (упрощённо):var mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
var options = {
useMongoClient: true
};
mongoose.connect('mongodb://localhost:27017/todo', options);
module.exports = mongoose;
var mongoose = require('../lib/mongooseConnect');
var TaskSchema = mongoose.Schema({
title: String,
isDone: String
});
var Task = mongoose.model('Task', TaskSchema);
module.exports = Task;
var Tasks = require('./models/Task');
// new Tasks({
// title: 'Task',
// isDone: 'Yes!'
// }).save();
Tasks.findOne({ title: 'Task' }).exec(function(err, data) {
if(err) console.error(err);
console.log(data);
});
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/todo');
var Schema = mongoose.Schema;
var TaskSchema = new Schema({
title: String,
isDone: String
});
var Task = mongoose.model('Task', TaskSchema);