Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  156] [ 5]  / answers: 1 / hits: 18382  / 12 Years ago, thu, january 31, 2013, 12:00:00

I'm trying to get an existing user document using mongoose with express but I only get this:



/webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:162
if (obj && '_id' in obj) continue;
^
TypeError: Cannot use 'in' operator to search for '_id' in Account
at model.Document._buildDoc (/webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:162:27)
at model.Document (/webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:67:20)
at model.Model (/webroot/api.domain.com/production/node_modules/mongoose/lib/model.js:33:12)
at new model (/webroot/api.domain.com/production/node_modules/mongoose/lib/model.js:1663:11)
at Object.model (/webroot/api.domain.com/production/node_modules/mongoose/lib/model.js:1662:14)
at Object.findOrCreateOneForTwitter (/webroot/api.domain.com/production/models/account.coffee:60:17)
at module.exports.callback.error (/webroot/api.domain.com/production/endpoints/twitter.coffee:67:34)
at Twitter.get (/webroot/api.domain.com/production/node_modules/ntwitter/lib/twitter.js:85:7)
at passBackControl (/webroot/api.domain.com/production/node_modules/oauth/lib/oauth.js:361:11)
at IncomingMessage.exports.OAuth._performSecureRequest.request.on.callbackCalled (/webroot/api.domain.com/production/node_modules/oauth/lib/oauth.js:380:9)


Is there any known fix for that? Thanks.


More From » node.js

 Answers
83

This error is not specific to Mongoose; it would show if obj is not an object, but a string for instance:



var obj = 'Account';
'id' in obj;
// TypeError: Cannot use 'in' operator to search for 'id' in Account


Assuming that it's not a Mongoose issue, you'd be looking somewhere here:



at Object.findOrCreateOneForTwitter 
(/webroot/api.domain.com/production/models/account.coffee:60:17)

[#80507] Wednesday, January 30, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;