mysql - Q:Bookshelf.js:How to query by bookshelfjs? -


i use method bookshelfjs.org query datas. there bug! code.

var defray = db.model.extend({     tablename: 'defray',     idattribute: 'id' }); new defray.query('where', 'purchaseid', '=', '2').fetch().then(function(model) {     console.log(model); }); 

the database mysql,and want use sql like

select * defray purchaseid = 2; 

bug info is

var model = this.forge();                        ^  typeerror: this.forge not function     @ new model.(anonymous function).collection.(anonymous function) (e:\wordspace\javascript\hekr_end\node_modules\bookshelf\lib\bookshelf.js:329:24)     @ object.<anonymous> (e:\wordspace\javascript\hekr_end\database\model.js:30:1)     @ module._compile (module.js:435:26)     @ object.module._extensions..js (module.js:442:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:313:12)     @ module.require (module.js:366:17)     @ require (module.js:385:17)     @ object.<anonymous> (e:\wordspace\javascript\hekr_end\routes\index.js:6:13)     @ module._compile (module.js:435:26)     @ object.module._extensions..js (module.js:442:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:313:12)     @ module.require (module.js:366:17)     @ require (module.js:385:17)     @ object.<anonymous> (e:\wordspace\javascript\hekr_end\app.js:15:14)     @ module._compile (module.js:435:26)     @ object.module._extensions..js (module.js:442:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:313:12)     @ module.require (module.js:366:17)     @ require (module.js:385:17)  npm err! windows_nt 10.0.10586 npm err! argv "c:\\program files\\nodejs\\node.exe" "c:\\program files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "start" npm err! node v4.2.4 npm err! npm  v2.14.12 npm err! code elifecycle npm err! app9d@0.0.0 start: `node ./bin/www` npm err! exit status 1 npm err!  npm err! failed @ app9d@0.0.0 start script 'node ./bin/www'. npm err! problem app9d package, npm err! not npm itself. npm err! tell author fails on system: npm err!     node ./bin/www npm err! can info via: npm err!     npm owner ls app9d npm err! there additional logging output above.  npm err! please include following file support request: npm err!     e:\wordspace\javascript\hekr_end\npm-debug.log 

the sql can run @ cmd,but can`t use bookshelf achieve target. me,please!

queries model feature not instance one. change code query directly on defray model, like:

var defray = db.model.extend({     tablename: 'defray'  // id not needed, default pk name }); defray.query('where', 'purchaseid', '=', '2').fetch().then(function(model) {     console.dir(model); }); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -