bhoriuchi / bookshelf-pagemaker Goto Github PK
View Code? Open in Web Editor NEWCustomizable pagination for bookshelf models
Customizable pagination for bookshelf models
first of all great job !!
pagemaker(Model.QuoteTag).forge()
.query(function(qb) {
qb.where('tag_id_id', 'LIKE', result.get('id'));
})
.paginate({
request: req
})
.end()
.then(function (data) {
res.json(data);
});
result of this query is not giving filted total pages I mean
if I have total 10000 data and 100 data belongs to x,
and when I am searching for x it showing total 10000 not 100 (suppose limit is 1)
here is the orignal result
{
"previous": "URLpage=101",
"current": "URLpage=102",
"next": "URLpage=103",
"limit": 40,
"pagesTotal": 2877,
"pagesFiltered": 2877,
"resources": [
// null bcz totalPage is 105 but showing 2877 !!
// 2877 is actual totalPage without where clause
]
}
We need define tag for releases for this project.
please help me :(
controller:
pm(User, 'datatables').forge()
.limit(req.query.start)
.paginate({
request: req,
withRelated: ['location', 'division'],
})
.end()
.then(function(results) {
res.send(results);
});
view:
$("#data-users").DataTable({
"order": [[ 2, "asc" ]],
"aoColumnDefs": [{ 'bSortable': false, 'aTargets': [0 , 1, 8] }],
"processing": true,
"serverSide": true,
"ajax": {
url: "/users/data",
type: 'GET'
},
})
Hi bhoriuchi, please help me
Controller:
pm(PartCondition, 'datatables').forge()
.paginate({
request: req,
withRelated: ['part'],
})
.end()
.then(function(results) {
res.send(results);
});
View:
$("#data-partConditions").DataTable({
"processing": true,
"serverSide": true,
"ajax": {
url: "/conditions/data",
type: 'GET'
},
"columns": [
{ "data": "part.name",
orderable: true },
{ "data": "description",
orderable: true },
]
})
When I clicked Description column, sorting was worked, but when I clicked Part Column not worked.
Is it possible to sorting related column with bookshelf-pagemaker?
Thanks
The withRelated
not working for me... I have this code.
var Doctor = ORM.Model.extend({
tableName: 'doctors',
});
var Pacient = ORM.Model.extend({
tableName: 'pacients',
hasTimestamps: true,
doctor: function() {
return this.belongsTo(Doctor, 'doctor_id');
}
});
if I use this:
new Pacient()
.fetchAll({ withRelated: ['doctor'] })
.then(function (pacientes) {
// Result
[
{
id: 1,
name: 'Paciente name',
doctor_id: 3,
doctor: {
id: 3,
name: 'Doctor name',
}
}
]
});
But if I use pagination my result is this:
pm(Pacient)
.forge()
.paginate({ withRelated: ['doctor'] })
.end()
.then(function (pacientes) {
// Result
[
{
id: 1,
name: 'Paciente name',
doctor_id: 3
}
]
});
sorry for my bad english...
We need make unit tests for this project.
What do you think?
How would I set the path for the currentPage/next/previous? By default it looks like it pulls the tableName if schema._path.path is not set, but I could not find in the code where that could be set.
How can I get the total rows?
var pm = require('bookshelf-pagemaker')(bookshelf);
var User = bookshelf.Model.extend({
tableName: 'users'
});
pm(User).forge()
.limit(2)
.page(2)
.paginate()
.end()
.then(function(results) {
console.log(results.total);
});
What if i want to search in a related table? What can i do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.