Promise typing issue?

17 views
Skip to first unread message

Jan Paul Erkelens

unread,
Jan 10, 2014, 4:03:09 PM1/10/14
to mongoo...@googlegroups.com
I've been using mongooses promises recently, and they're really great. I'm writing code that can take a Query object or a Promise object and resolve them accordingly. That code uses 

if (item instanceOf Query) {..}
else {...}

to discern between the two.

However, it seems as if mongoose's promises are returning true for the instance query. I'm using 3.8.0 but upgrading to 3.8.4 gives the same result. Here's an example of a promise I'm building

  var p = this.find(cond).sort('endDate').populate('_artist').exec().then(ƒ(docs) {
     return Model.populate(docs, {path: 'pathName'})
    })

  console.log(p instanceof Query) //logs true
  console.log(p instanceof Promise) //logs false

This seems incorrect to me. Am I doing anything wrong?

Aaron Heckmann

unread,
Jan 13, 2014, 12:21:37 PM1/13/14
to mongoo...@googlegroups.com
looks ok to me. double check the rest of the code. if you're still stuck, please post a runnable gist which reproduces the issue.
--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


--

Reply all
Reply to author
Forward
0 new messages