查询出来是一堆没用的东西呢,为啥不是文档呢:
//db.js var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/mybooks'); module.exports = mongoose;
//find.js var mongoose = require('./db'); var Schema = mongoose.Schema; var booksSchema = new Schema({ name: String, author: String });
var bookModel = mongoose.model('ctbook', booksSchema); console.log(bookModel.find());
{ _mongooseOptions: {}, mongooseCollection: { collection: null, opts: { bufferCommands: true, capped: false }, name: 'ctbooks', conn: { base: [Object], collections: [Object], models: {}, replica: false, hosts: null, host: 'localhost', port: 27017, user: undefined, pass: undefined, name: 'mybooks', options: [Object], otherDbs: [], _readyState: 2, _closeCalled: false, _hasOpened: false, _listening: false, _events: {}, db: [Object] }, queue: [], buffer: true }, model: { [Function: model] base: { connections: [Object], plugins: [], models: [Object], modelSchemas: [Object], options: [Object] }, modelName: 'ctbook', model: [Function: model], db: { base: [Object], collections: [Object], models: {}, replica: false, hosts: null, host: 'localhost', port: 27017, user: undefined, pass: undefined, name: 'mybooks', options: [Object], otherDbs: [], _readyState: 2, _closeCalled: false, _hasOpened: false, _listening: false, _events: {}, db: [Object] }, discriminators: undefined, schema: { paths: [Object], subpaths: {}, virtuals: [Object], nested: {}, inherits: {}, callQueue: [], _indexes: [], methods: {}, statics: {}, tree: [Object], _requiredpaths: undefined, discriminatorMapping: undefined, _indexedpaths: undefined, options: [Object], _events: {} }, options: undefined, collection: { collection: null, opts: [Object], name: 'ctbooks', conn: [Object], queue: [], buffer: true } }, op: 'find', options: {}, _conditions: {}, _fields: undefined, _update: undefined, _path: undefined, _distinct: undefined, _collection: { collection: { collection: null, opts: [Object], name: 'ctbooks', conn: [Object], queue: [], buffer: true } }, _castError: null }