English 中文(简体)
MIsingSchema 错误: Schema hasn t被登记为“Emp”模式
原标题:MIssingSchemaError: Schema hasn t been registered for model "Emp"

我尝试了在四舍五入时可用的不同解决办法,但无法解决这一问题。

我的法典

var mongoose = require( mongoose );

var schema = new mongoose.Schema({
    name:{
        type:String,
        required:true
    },
    email:{
        type:String,
        required:true,
        lowercase:true
    }
});
mongoose.connect( mongodb://localhost:27017/test );
//parameters are model name,schema,collection name
var Emp = mongoose.model( Emp , schema , users );
最佳回答

你们正在使用模型方法的第二个参数,需要Schema。

这解决了你的问题:

var Emp = mongoose.model( Emp ,schema, users );

These are the parameter types you must use:

name         String   model name

schema       Schema

collection   String   name (optional, induced from the model name)

skipInit    Boolean whether to skip initialization (defaults to false)

more information here: http://mongoosejs.com/docs/api.html#index_Mongoose-model

问题回答

暂无回答




相关问题
Access DB Ref MongoDB

Whats the best way to access/query a DB Ref: UPDATE: users: name, groupref : {$ref:"groups",$id:"ObjectId ..." } } groups: name, topic, country,...,.. Assumption is that user belongs to only one ...

MongoDB nested sets

What re the best practices to store nested sets (like trees of comments) in MongoDB? I mean, every comment can have a parent comment and children-comments (answers). Storing them like this: { ...

MongoMapper and migrations

I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...

MongoDB takes long for indexing

I have the following setup: Mac Pro with 2 GB of RAM (yes, not that much) MongoDB 1.1.3 64-bit 8 million entries in a single collection index for one field (integer) wanted Calling .ensureIndex(...) ...

Storing and accessing large amounts of data

My application creates pieces of data that, in xml, would look like this: <resource url="someurl"> <term> <name>somename</name> <frequency>somenumber</...

热门标签