最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

为树视图填充mongoose co

运维笔记admin11浏览0评论

为树视图填充mongoose co

为树视图填充mongoose co

我创建了以下mongoose模式

工作空间model.js

var mongoose=require('mongoose')
var uniqueValidator=require('mongoose-unique-validator');
var workspaceSchema=new mongoose.Schema({
  name:{type: String, lowercase: true, required: [true, "can't be blank"],
  //match: [/^[a-zA-Z0-9]$/, 'is invalid'],
  index: true,
  unique: true
},
  processes:[{type:mongoose.Schema.Types.ObjectId,ref:'Process'}],

  },{timestamp:true})

workspaceSchema.plugin(uniqueValidator,{message:'is already taken'});

module.exports=mongoose.model('Workspace',workspaceSchema)
回答如下:

问题是console.log在2-3级嵌套级别后无法打印。解决方案如下

var util = require('util')

  .....
//following line will print nested objects
console.log(util.inspect(data, false, null))
  ....

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论