我在MongoDB中有ug.tutionfees和pg.tutionfees之类的数据。如何在NodeJS模型类中实现这些数据以及angular plz告诉我。
我的模型班:
const mongoose = require('mongoose');
const UniversitySchema = mongoose.Schema({
worldranking:String,
countryranking:String,
universityname:String,
bachelorprogram:String,
masterprogram:String,
phdprogram:String,
country:String
},{collection:'us'});
const University =module.exports = mongoose.model('University',UniversitySchema);
我想在此模型类中实现ug.tutionfees
和pg.tutionfees
。
答案 0 :(得分:0)
如果只有ug.tutionfees
和pg.tutionfees
这两个不同的对象,则可以将其添加到架构中,如下所示:
ug :{
tutionfees :{
type: String
}
},
pg :{
tutionfees :{
type: String
}
}
检查我的架构结构之一:
'use strict'
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var rbpiSchema = new Schema({
rbpiId: {
type: String,
required: true,
unique: true
},
name: {
type: String,
required: true
},
description: {
type: String
},
last_action: {
activity: {
type: String
},
status: {
type: String
},
ut: {
type: Number
},
description: {
type: String
}
},
ct: {
type: Number,
require: true,
default: new Date().getTime()
},
ut: {
type: Number,
require: true,
default: new Date().getTime()
}
});
module.exports = mongoose.model('rbpi', rbpiSchema);