router.get('/', function(req, res, next) {
// res.render('index', { title: 'Express' });
const model = mongoose.model('realestate');
const queryCretia = {};
model.find(queryCretia, (err, docs) => {
res.render('index', {
title: 'express',
docs: docs
})
})
});
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h1><%= title %></h1>
<p>Welcome to <%= title %></p>
<!-- <%= docs %> -->
<ul>
<% docs.forEach(function(doc){ %>
<li><%= doc.type %></li>
<% }) %>
</ul>
</body>
</html>
[{
"_id" : ObjectId("59bdeadb2a5c612514ee7970"),
"title" : "好楼层,中等装修,满5年,上门实拍",
"type" : "2室1厅",
"square" : "75.42平",
"direction" : "朝南",
"floor" : "中区/6层",
"unitPrice" : 47732,
"totalPrice" : 360,
"location" : null,
"specialExplain" : "满五",
"url" : "http://sh.lianjia.com//ershoufang/sh4528035.html",
"station" : "江杨北路",
"line" : "3号线",
"updateTime" : "2017-09-17 11:24:11"
}
{
"_id" : ObjectId("59bdeadb2a5c612514ee7971"),
"title" : "南北户型,厨卫全明,高区采光好,装修精美",
"type" : "2室2厅",
"square" : "90.92平",
"direction" : "朝南北",
"floor" : "高区/6层",
"unitPrice" : 46194,
"totalPrice" : 420,
"location" : null,
"specialExplain" : "满五",
"url" : "http://sh.lianjia.com//ershoufang/sh4546221.html",
"station" : "江杨北路",
"line" : "3号线",
"updateTime" : "2017-09-17 11:24:11"
}]
docs.forEach(doc => {
return doc.toObject();
})
docs = JSON.stringify(docs); docs = JSON.parse(docs);
model.find().lean().exec((err, docs) => {
....
})
console.log(Object.prototype.toString.call(docs)); consoele.log(Object.prototype.toString.call(docs[0])); console.log(Object.prototype.toString.call(docs1)); console.log(Object.prototype.toString.call(docs1[0]))
[object Array] [object Object] [object Array] [object Object]
console.dir(doc[0].__proto__); console.dir(docs[0].__proto__);
model {
db:
NativeConnection {
base:
Mongoose {
connections: [Array],
models: [Object],
modelSchemas: [Object],
options: [Object],
plugins: [Array] },
collections: { realestates: [Object] },
models: { realestate: [Object] },
config: { autoIndex: true },
replica: false,
hosts: null,
host: '127.0.0.1',
port: 27017,
user: undefined,
pass: undefined,
name: 'real_estate_info',
options:
{ db: [Object],
auth: {},
server: [Object],
replset: [Object],
mongos: undefined },
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db:
Db {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
s: [Object],
serverConfig: [Getter],
bufferMaxEntries: [Getter],
databaseName: [Getter],
_listening: true },
_events:
{ connected: [Function],
error: [Function: bound bound consoleCall],
disconnected: [Function: bound bound consoleCall],
reconnected: [Function: bound bound consoleCall] },
_eventsCount: 4 },
discriminators: undefined,
id: [Getter/Setter],
__v: [Getter/Setter],
_id: [Getter/Setter],
schema:
Schema {
obj: undefined,
paths: { _id: [Object], __v: [Object] },
aliases: {},
subpaths: {},
virtuals: { id: [Object] },
singleNestedPaths: {},
nested: {},
inherits: {},
callQueue: [ [Array], [Array], [Array], [Array], [Array], [Array] ],
_indexes: [],
methods: {},
statics: {},
tree: { _id: [Object], __v: [Function: Number], id: [Object] },
query: {},
childSchemas: [],
plugins: [ [Object], [Object], [Object], [Object] ],
s: { hooks: [Object], kareemHooks: [Object] },
options:
{ retainKeyOrder: false,
typeKey: 'type',
id: true,
noVirtualId: false,
_id: true,
noId: false,
validateBeforeSave: true,
read: null,
shardKey: null,
autoIndex: null,
minimize: true,
discriminatorKey: '__t',
versionKey: '__v',
capped: false,
bufferCommands: true,
strict: true,
pluralization: true },
'$globalPluginsApplied': true,
_requiredpaths: [] },
collection:
NativeCollection {
collection: Collection { s: [Object] },
opts: { bufferCommands: true, capped: false },
name: 'realestates',
collectionName: 'realestates',
conn:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
hosts: null,
host: '127.0.0.1',
port: 27017,
user: undefined,
pass: undefined,
name: 'real_estate_info',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db: [Object],
_events: [Object],
_eventsCount: 4 },
queue: [],
buffer: false,
emitter:
EventEmitter {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined } },
'$__original_save': { [Function] numAsyncPres: 0 },
save: { [Function: wrappedPointCut] '$originalFunction': '$__original_save', '$isWrapped': true },
_pres:
{ '$__original_save': [ [Object], [Object], [Object] ],
'$__original_remove': [ [Object] ] },
_posts: { '$__original_save': [], '$__original_remove': [] },
'$__original_remove': { [Function] numAsyncPres: 1 },
remove:
{ [Function: wrappedPointCut]
'$originalFunction': '$__original_remove',
'$isWrapped': true },
'$__original_validate': [Function],
validate:
{ [Function: wrappedPointCut]
'$originalFunction': '$__original_validate',
'$isWrapped': true } }
{}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有