Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  30] [ 4]  / answers: 1 / hits: 18345  / 7 Years ago, sat, june 24, 2017, 12:00:00

In node.js I have three variables:



var name = 'Peter';
var surname = 'Bloom';
var addresses = [
{street: 'W Division', city: 'Chicago'},
{street: 'Beekman', city: 'New York'},
{street: 'Florence', city: 'Los Angeles'},
];


And schema:



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

var personSchema = Schema({
_id : Number,
name : String,
surname : String,
addresses : ????
});


What type and how do I use it in schema? How is the best way for this?


More From » node.js

 Answers
6

You must create another mongoose schema:



var address = Schema({
street: String,
city: String});



And the type of addresses will be Array< address >


[#57313] Thursday, June 22, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;