testing - MongoDB/Mongoose: embedded document update verification -


how verify/test on mongoose, document update call, embedded documents not being duplicated?

i'm using mongoose, sinon, mocha , chai. have document contains embedded document, , both created external data pulled @ regular intervals.

format similar to:

{   title: testingtitle,   flag: true,   color: orange,   list: [{       name: testname,       status: overdue   },   {       name: othertestname,       status: due,   }] } 

i have 2 separate schemas. format similar this:

let embeddedschema = new mongoose.schema({      name: {type: string, required: true},      staus: {type: string, required: true}      createdat: {type: date, default: moment} });  let mainschema = new mongoose.schema({       title: {type: string, required: true},       flag: {type: string, defualt: null},       color: {type: object, defualt: null},       list: [embeddedschema] }) 

it seems works. when run logic (which calls update if main document exists) doesn't appear duplicate of sublist items. unfortunately way system set it's difficult verify truth.

  1. is there blatantly wrong set up? main concern every item in list potentially duplicated, instead of updated on changes, because there no uniqueid connect them stored items.
  2. how go testing using sinon?


Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

asp.net mvc - how to pass 'true'/'false' data from Controller to View using jquery for bootstrap validator in MVC -