dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 376 forks source link

TypeError: other.save is not a function #708

Open ghost opened 8 years ago

ghost commented 8 years ago

I get this error when i use hasone like this: ti_attach.hasOne('news' ,db.models.ti_news , {field :'root_id' ,reverse:'covers' ,autoFetch:true}); and then req.models.ti_news.create(params ,function(err ,data){ if(err) return next(err); data.setCovers(attaches, function(err){ if(err) return next(err); res.json({err :0}); }) })

finally ,i get these problem TypeError: other.save is not a function at saveNext (F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Association One.js:230:13) at F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Associations\One.js:2 :13 at F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Instance.js:631:12 at Instance.saveInstanceExtra (F:\开发\nodejs\CarsClub\node_modules\node-o \lib\Instance.js:353:19) at finish (F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Instance.js:2 :5) at F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Instance.js:252:8 at Instance.saveAssociations (F:\开发\nodejs\CarsClub\node_modules\node-or lib\Instance.js:348:11) at next (F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Instance.js:245 ) at Instance.savePersisted (F:\开发\nodejs\CarsClub\node_modules\node-orm\l \Instance.js:260:4) at F:\开发\nodejs\CarsClub\node_modules\node-orm\lib\Instance.js:140:13

dxg commented 8 years ago

Please provide a complete code sample like this. Also please use '```' for code blocks.