mongoose与父id有很多关系

时间:2016-04-15 20:03:43

标签: node.js mongoose

我有一个Region模型和一个Activity模型。活动模型具有引用区域的region_id键。

在我对我的区域模型的定义中,我想让它参考所有它的活动,但是没有成功。有什么想法吗?

import mongoose, { Schema } from 'mongoose';
import Tag from './Tag';
const schema = new Schema({
  name: String,
  url: String,
  state: {type: String, default: 'California'},
  stateRrl: {type: String, default: null},
  longitude: String,
  latitude: String,
  country: {type: String, default: 'United States'},
  description: {type: String, default: ''},
  factsTitle: {type: String, default: ''},
  infoTitle: {String, default: ''},

  // Assocations
  activities: [{type: Schema.ObjectId, ref: 'Activity'}],
  tags: [{type: Schema.Types.ObjectId, ref: 'Tag'}]
});

0 个答案:

没有答案