Created
April 27, 2018 21:18
-
-
Save laerciobernardo/42bca9dca362dd64d55558aa8fb4fc95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
let avaliationItemSchema = new Schema({ | |
description: String, | |
_type: {type: Schema.Types.ObjectId, ref: 'avaliationType'}, | |
active: Boolean, | |
}); | |
//SubDocuments referred qrcode will be genereted | |
let tagSchema = new Schema({ | |
name: String, | |
description: String, | |
active: Boolean, | |
main: Boolean, //Describe what tag will be show when other methods company identification like (GPS) | |
avaliationItems:[avaliationItemSchema] | |
}); | |
let companySchema = new Schema({ | |
active: Boolean, | |
deleted: Boolean, | |
cnpj: String, | |
ie: String, | |
companyName: String, | |
tradingName: String, | |
urlLogo: String, | |
address: { | |
streetType: String, | |
street: String, | |
number: Number, | |
complement: String, | |
district: String, | |
zipCode: Number, | |
city: String, | |
state: String, | |
country: String | |
}, | |
phone: String, | |
emails: [String], | |
tags: [tagSchema] | |
}); | |
module.exports = mongoose.model('company', companySchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tenho uma função no meu controller para buscar uma company, e queria fazer um populate do atributo _type do Schema avaliationSchema, tentei assim mas não funcionou
const get = (uid) => { let query = {"_id": uid.toObjectId()}; return Model.findOne(query).populate('tags.avaliationItems._tagType'); };