Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongoose reference another model

var mongoose = require('mongoose')
  , Schema = mongoose.Schema

var eventSchema = Schema({
    title     : String,
    location  : String,
    startDate : Date,
    endDate   : Date
});

var personSchema = Schema({
    firstname: String,
    lastname: String,
    email: String,
    gender: {type: String, enum: ["Male", "Female"]}
    dob: Date,
    city: String,
    interests: [interestsSchema],
    eventsAttended: [{ type: Schema.Types.ObjectId, ref: 'Event' }]
});

var Event  = mongoose.model('Event', eventSchema);
var Person = mongoose.model('Person', personSchema);
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript compute heading on too points 
Javascript :: tailwindcss with django 
Javascript :: how to add json datasource in jasperserver 
Javascript :: automatic jquery interceptor with token 
Javascript :: choropleth map of india which shows current date confirmed cases in every state json api python. 
Javascript :: syntax to call item from array 
Javascript :: console log update status bar 
Javascript :: refresh token undefined in google auth passport js 
Javascript :: in object transform translate property concat with rotate value angular 7 
Javascript :: javascript for loop new line when getting to the end of screen 
Javascript :: react router tutorial medium 
Javascript :: node js reuire json shows onject 
Javascript :: how to set input of time type to current time on initialization 
Javascript :: loopback merge data and update 
Javascript :: jquery delete buton 
Javascript :: js resize div with mouse 
Javascript :: react how to block render if data is not fetched yet 
Javascript :: site completo com ajax jquery 
Javascript :: Ajax send date to MVC 
Javascript :: How to check all checkboxes using jQuery? Ask Question 
Javascript :: class in side class in jss 
Javascript :: how to add functionality inside js object 
Javascript :: how can we give the index of an array as an ID to an element 
Javascript :: wait in js 
Javascript :: javascript loop area 
Javascript :: validate url javascript 
Javascript :: javascript mvc patetern 
Javascript :: react route send informaion in url 
Javascript :: oracle apex interactive grid set record field readonly 
Javascript :: replace all commas in string javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =