node.js - mongoose, how to create a schema has object in it? -


here's photoschema. has dbentry object. should create dbentry schema , ref in photoschema. or whatever have enough? new mongodb, try figure out correct way create schema.

    var photoschema = new mongoose.schema({         userid:         objectid,         type:           string,         createdon:      {type: date, default: date.now},         isdeleted:      {type: boolean, default: false},         isdownloaded:   {type: boolean, default: false},          dbfile: string,         dbentry: {             revision:       number,             rev:            string,             thumb_exists:   boolean,             bytes:          number,             modified:       date,             client_mtime:   date,             path:           { type: string, unique: true}         }     }); 

it depends on how plan access data. if want dbentry object each time query photoschema document, have way go.

if however, you're going use dbentry independent of photoschema document, should split , keep ref it.

you can fetch ref using mongoose "populate"


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -