Model.fetchAll not working
See original GitHub issueWhen I am trying to all all object via Bookshelf then it is returning incorrect result.
var uuid = require('node-uuid');
var Bookshelf = require('bookshelf');
var Knex = require('knex');
var bookshelf = Bookshelf(Knex({}));
var schema = bookshelf.knex.schema;
schema.createTable('binary_uuid_test', function(table) {
table.binary('uuid');
table.string('name');
})
it('loads objects properly', function() {
// These are uuid.v1()
var uuids = ['d96d40d1-fcc9-11e5-9b8d-87b1687276b9', 'd96d40d2-fcc9-11e5-9b8d-87b1687276b9'];
var s_uuids = ['d96d40d1-fcc9-11e5-9b8d-87b1687276b9', 'd96d40d2-fcc9-11e5-9b8d-87b1687276b9'];
var SubSite = bookshelf.Model.extend({
idAttribute: 'uuid',
tableName: 'binary_uuid_test',
initialize: function() {
this.on('saving', this._generateId);
},
_generateId: function (model, attrs, options) {
if (model.isNew()) {
model.set(model.idAttribute, buildBuffer(uuids.pop()));
}
}
});
function buildBuffer(string) {
return (new Buffer(uuid.parse(string)));
}
var subsite = new SubSite({ name: 'Kuldeep Aggarwal' }),
subsite1 = new SubSite({ name: 'Kd Aggarwal' });
return Promise.all([subsite1.save(), subsite.save()])
.then(function() {
return SubSite.fetchAll()
.then(function(collection) {
expect(_.map(collection.models, function(model) {
return uuid.unparse(model.id);
})).to.eq(s_uuids);
});
});
});
This test is getting failed.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
IG cookbook model.fetchAll(function() {}); NOT working
fetchAll (function() {}); NOT working. I'm using apex 20.2 and universal theme. I copied the code in the IG Cookbook dynamic total below....
Read more >cursor.fetchall() or other method fetchone() is not working
After trying it multiple times. I understand that you always have to commit ( db.commit() ) your transaction into databases before executing ...
Read more >PDOStatement::fetchAll - Manual - PHP
If you are trying to call PDOStatement::fetchAll and is not getting the result set as expected (empty instead), check if you called PDOStatement::execute...
Read more >sqlite3 — DB-API 2.0 interface for SQLite databases — Python ...
First, we need to create a new database and open a database connection to allow sqlite3 to work with it. Call sqlite3.connect() to...
Read more >X DevAPI User Guide :: 9.4 Fetching All Data Items at Once
... of using fetchOne() explained at Section 9.3, “Working with Data Sets”, ... X DevAPI also provides a pattern using fetchAll() , which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Other way around.
parse: columns -> attributes format: attributes -> columns
The project leadership of Bookshelf recently changed. In an effort to advance the project we close all issues older than one year.
If you think this issue needs to be re-evaluated please post a comment on why this is still important and we will re-open it.
We also started an open discussion about the future of Bookshelf.js here https://github.com/bookshelf/bookshelf/issues/1600. Feel free to drop by and give us your opinion. Let’s make Bookshelf great again