nodeclub models

之前看过keystone的结构,所以现在看nodeclub时,总会和keystone进行比较。

nodeclub models会有一个index来作为facade,通过它连接mongodb,exports具体的model

在keystone中,models没有连接mongodb的部分,也没有index作为facade,直接require 文件夹名,把各具体的model作为它的属性来使用。keystone 连接mongodb的在哪呢?

 

mongoose.connect(uri, options)

options的参数如下

db - passed to the connection db instance
server - passed to the connection server instance(s)
replset - passed to the connection ReplSet instance
user - username for authentication (if not specified in uri)
pass - password for authentication (if not specified in uri)
auth - options for authentication
mongos - Boolean - if true, enables High Availability support for mongos

 

process.exit(1):退出并返回失败的状态 ('failure' code);执行上述代码,用来执行 node 的 shell 就能收到值为 1 的 exit code

 

如果不require,应该也可以吧,没有赋给变量,也没有使用

 

user的数据划分很好,.index建立索引,-1反向 unique唯一性

 

schema.plugin(): 使用插件,schema.plugin(model):对schema使用model

 

现在看的版本中去掉了tag和relation

 

敲完了models,也就熟悉了nodeclub中models的使用。

posted on 2015-10-12 10:13  j.w  阅读(292)  评论(0编辑  收藏  举报