20
我想在mongodb中爲每個集合使用多個模式,如何使用它....?
它給了我這個錯誤,當我嘗試運行它:
錯誤:在mongodb上爲每個集合使用多個模式
OverwriteModelError: Cannot overwrite
allUsers
model once compiled.
OverwriteModelError: Cannot overwritecheckInOut
model once compiled.
我的繼承人schema.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema
, ObjectId = Schema.ObjectId;
var checkInInfoSchema= new Schema({
name:String,
loginSerialId:Number
});
var loginUserSchema = new Schema({
sn : { type: Number, unique:true }
,uname: {type:String, unique:true}
,pass:String
});
var registerUserSchema = new Schema({
sn : { type: Number, unique:true }
, name: String //his/her name
,pass:String,
companyKey:{type:String},
uname:{type:String,unique:true}
});
var checkInOutSchema = new Schema({
uname: String
,companyKey:String
,task:String
,inTime:String
,outTime:String
,date:{type:String}
,serialId:{type:Number,unique:true}
,online:Boolean
});
//Different schema for same collection "allUsers"
var allUser=mongoose.model('allUsers',loginUserSchema);
var registerUser=mongoose.model('allUsers',registerUserSchema);
//Different schema for same collection "checkInOut"
var checkInOut=mongoose.model('checkInOut',checkInOutSchema);
var checkInInfo=mongoose.model('checkInOut',checkInInfoSchema);
module.exports={
allUser:allUser,
registerUser:registerUser,
checkInOut:checkInOut,
checkInInfo:checkInInfo
};
我給了他們相同的名字,並不知道集合的名字預計在第三個參數中。 –
任何建議如何做兩種模式的搜索對象的方法?例如 我想查找用戶和註冊用戶,並按日期對其進行排序,只使用查詢。 – Leg0
Leg0,jQuery與此有什麼關係? – bluehallu