node.js - Mongoose query for embedded mongodb documents -


here's schema:

var videonode = new mongoose.schema({         title: string,         uid: string,         v_url:string,         t1:number,         t2:number,         f_url:string,         fullvideo: boolean,         parentmap: string,         creator: string,         description_note: string,         bookmarks: [ bookmark ],     threads: [ string ],         annotations: [ annotation ],             cons:   [string],         justadded:  boolean,         position: { top: number, left: number } });  var annotation = new mongoose.schema({     starttime  : date,         dateadded  : date,         text       : string,         type_icon  : string,         author     : string,     messages   : [message],         voters     : [string],         annotation_type : string,         stime_inseconds : number }); 

i'm trying query "annotations" user "logged in".

here's query:

socket.on('annotations:read', function (data, callback) {          console.log("finding annotations author = username passed in 'data' parameter");                  console.log("user logged in is:" + data.username);             videonodemodel.findone( {'annotations.author': data.username},'title creator annotations', function( err, videonode ) {             console.log( "found videonodes first query" );             if( !err ) {                 console.log('videonodes found method are:' + videonode);                  videonode.annotations.find({author:data.username},['annotations.author annotations.text'], function(err, annotations){                   if(annotations){                     console.log( "found annotations" );                     socket.emit('catchresults', {result: annotations}); // event returns client result of query                     console.log('annotations found method are:' + annotations);                   } else {                     console.log('no annotations found');                   }             });          } });        }); 

however end error when query exectuted. query finds videonode author of annotation logged in user, when runs videonode.annotations.find fails go past "messages" field inside annotation schema. , error messages: [] } has no method 'find'. 1 please suggest way avoid error , annotations particular user.

any ideas? did experience similar?

thanks lot in advance! appreciate help!


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -