伙计我不明白我为什么不从MongoDB获取数据。相反,我得到了这个对象:
_mongooseOptions: {},
mongooseCollection:
NativeCollection {
collection: null,
opts: { bufferCommands: true, capped: false },
name: 'products',
collectionName: 'products',
conn:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
..........
.....and so on
这是我的代码:
var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
var Product = require('../models/product');
router.get('/', function(req, res, next) {
var items = Product.find();
console.log(items);
});
答案 0 :(得分:2)
CategoryId
返回一个Query对象。请参阅此处的文档:http://mongoosejs.com/docs/queries.html
要获取实际数据,您必须提供回调:
Product.find()
您可以在官方快速入门中看到更多相关示例:http://mongoosejs.com/docs/index.html