Я пытаюсь получить все имена мангуст модели и перебирать корыта их зрения (test.jade
)итерация корыто mongoose.models
маршрут
router.get('/dashboard', ensureAuthenticated, function (req, res) {
var models = mongoose.models;
console.log(models);
res.render('test',{data:models});
})
я получил этот журнал на консоли узла:
{ User:
{ [Function: model]
base:
{ connections: [Object],
plugins: [],
models: [Circular],
modelSchemas: [Object],
options: [Object] },
modelName: 'User',
model: [Function: model],
db:
{ base: [Object],
collections: [Object],
models: [Circular],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: '',
pass: '',
name: 'simpleblog',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: true,
_events: {},
db: [Object] },
discriminators: undefined,
schema:
{ paths: [Object],
subpaths: {},
virtuals: [Object],
nested: {},
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
statics: {},
tree: [Object],
_requiredpaths: [],
discriminatorMapping: undefined,
_indexedpaths: undefined,
options: [Object],
_events: {} },
options: undefined,
collection:
{ collection: [Object],
opts: [Object],
name: 'users',
conn: [Object],
queue: [],
buffer: false } },
Comment:
{ [Function: model]
base:
{ connections: [Object],
plugins: [],
models: [Circular],
modelSchemas: [Object],
options: [Object] },
modelName: 'Comment',
model: [Function: model],
db:
{ base: [Object],
collections: [Object],
models: [Circular],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: '',
pass: '',
name: 'simpleblog',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: true,
_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: [Object],
opts: [Object],
name: 'comments',
conn: [Object],
queue: [],
buffer: false } },
Article:
{ [Function: model]
base:
{ connections: [Object],
plugins: [],
models: [Circular],
modelSchemas: [Object],
options: [Object] },
modelName: 'Article',
model: [Function: model],
db:
{ base: [Object],
collections: [Object],
models: [Circular],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: '',
pass: '',
name: 'simpleblog',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: true,
_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: [Object],
opts: [Object],
name: 'articles',
conn: [Object],
queue: [],
buffer: false } } }
вид
for(var prop in data)
p #{prop}: #{data[prop]}
проблема заключается в том, что я не мог получить какой-либо результат после операции итерации по мнению
ли остальной вид из 'теста. jade' получится правильно? Если вы добавите 'console.log (models)' прямо после 'router.get (...) {', вы видите, что что-то печатается в консоли узла? – pbkhrv
@pbkhrv 'test.jade' получается правильно обработанным, я его протестировал. и я также зарегистрировал модели внутри router.get, я получил результат, который я поделюсь им при следующем редактировании. – semirturgay
Я ожидаю увидеть что-то вроде журнала node.js ... в настоящее время я не вижу никакого вывода на моем представлении – semirturgay