dycodedev / mongo-datatable Goto Github PK
View Code? Open in Web Editor NEWNodeJS module for server-side processing using jquery datatables and mongodb native driver.
License: MIT License
NodeJS module for server-side processing using jquery datatables and mongodb native driver.
License: MIT License
I tried adding caseInsensitive to both my jquery
$("#data-table").DataTable({
"pageLength": 100,
"aoColumnDefs": [
{ "mData": "archived", "name": "archived", "aTargets": 0},
{ "mData": "offerId", "name": "offerId" , "aTargets": 1 },
{ "mData": "cpaNetwork", "name": "cpaNetwork", "aTargets": 2 },
{ "mData": "voluumOfferName", "name": "voluumOfferName", "aTargets": 3 },
{ "mData": "carrier", "name": "carrier", "targets": 4 },
{ "mData": "countryCode", "name": "countryCode", "aTargets": 5 },
{ "mData": "cpaOfferId", "name": "cpaOfferId", "aTargets": 6 },
{ "mData": "dateCreated", "name": "dateCreated", "aTargets": 7 },
{ "mData": "dateUpdated", "name": "dateUpdated", "aTargets": 8 },
{ "mData": "shortName", "name": "shortName", "aTargets": 9 },
{ "mData": "offerUrl", "name": "offerUrl", "aTargets": 10 },
{ "mData": "country", "name": "country", "aTargets": 11 },
{ "mData": "shortCyrptoName", "name": "shortCyrptoName", "aTargets": 12 },
{ "mData": "fullCryptoName", "name": "fullCryptoName", "aTargets": 13 },
{ "mData": "payout", "name": "payout", "aTargets": 14 },
],
"order": [[8, "desc"]],
"processing": true,
"search": {
"caseInsensitive": true
},
serverSide: true,
ajax: {
url: '/offers/offerDbSearch',
type: 'GET'
},
});
and also my node script
var options = req.query;
options.search.caseInsensitive = true
Without caseInsensitive working, my search results are always a bit skewed. Any ideas?
with this version 3.0 of mongoclient (mine), i have to init options with :
options.search = {value : ""};
for not having assert error !
even with this line, using the sample code, i have the foowing result :
{
"draw": 0,
"recordsTotal": 0,
"recordsFiltered": 0,
"data": [],
"error": "Columns must be defined!"
}
very strange !
I'm trying to understand how this tool works. I keep getting responses of:
{
draw: 0,
recordsTotal: 0,
recordsFiltered: 0,
data: [ ],
error: null
}
No errors, but no results either. I can see that the database has at least ten entries, and I can manually generate them using
db.collection('clients').find({}).toArray(function(err, result) {
if (err) {
console.log(err);
} else if (result.length) {
res.send("<html><body>" + JSON.stringify(result, null, 4) + "</body></html>");
} else {
console.log('No document(s) found with defined "find" criteria!');
}
db.close();
Its not at all clear to me on how to do the setup so the DB returns the correct (all!) data fields, while utilizing the mongo-datatable tool correctly... Any hints on how to proceed? (I'd be happy to provide a minimal example, including populating the MongoDB so its clear to all, but I can't figure this out...)
So I added some error testing after new MongoDataTable(db).get('clients', options, function(err, result) {
and I'm seeing AssertionError: failures. Not sure what's causing that.
Can someone tell me what they are using for options
with a successful run? (preferably to return ALL data from a flat data collection. [i.e. no object hierarchy, no nested objects / arrays ] ..)
node_modules\mongo-datatable\lib\columns.js:7
var globalSearchValue = options.search.value;
^
TypeError: Cannot read property 'value' of undefined
at Object.buildSearchCriteria (C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongo-datatable\lib\columns.js:7:42)
at MongoDataTable.get (C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongo-datatable\lib\MongoDataTable.js:24:29)
at C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\index.js:47:28
at C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\utils.js:510:9
at C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\mongo_client.js:130:17
at connectCallback (C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\operations\connect.js:29:9)
at C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\operations\connect.js:80:9
at C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\sdam\topology.js:219:25
at C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\cmap\connection_pool.js:273:25
at handleOperationResult (C:\Users\Adam\Documents\github\socketIOtable-nodejs\socket-iotable-nodejs\node_modules\mongodb\lib\sdam\server.js:363:9)
Get this after trying to run for the first time.
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.