dycodedev/mongo-datatable

Not getting expected results.

Closed this issue · 1 comments

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 ] ..)

Hi,

Sorry for late response. Can you please provide me the jquery datatables initialization script? It will be helpful for me to reproduce and find out what's wrong.

Also, options parameter is actually a querystring / request body that is sent by jquery datatables which is described in this page. And that parameter tells this module about:

  • Number of rows of data that should be returned.
  • Columns that should be present on each row of data.
  • How the data should be sorted and filtered.

Thanks.