-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongo.js
More file actions
31 lines (28 loc) · 754 Bytes
/
mongo.js
File metadata and controls
31 lines (28 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let mongoose = require('mongoose'),
assert = require('assert');
let Schema = mongoose.Schema;
let bookSchema = new Schema({
title: String,
writers: String,
cover: String,
url: String,
rating: String,
rating_count: String
});
let book = mongoose.model('book', bookSchema);
//自动映射到films的collection
//自定义表名:let Film = new Schema({..}, { collection: 'name' });
// let db = mongoose.connect('mongodb://127.0.0.1:27017/nodejs-douban');
mongoose.connect('mongodb://yjx:123@127.0.0.1:27017/myfirstdb').then(
() => {
console.log("")
/** ready to use. The `mongoose.connect()` promise resolves to undefined. */
},
err => {
console.log(err);
/** handle initial connection error */
}
);
module.exports = {
book: book
};