Giter VIP home page Giter VIP logo

Comments (6)

eherve avatar eherve commented on September 10, 2024

Hello, thank you for using this module.
Can you give me more details about your issue ?

The module use the search string sent by the DataTable plug-in to do a like search on all columns of the table.
You just load the mongoose-datable module like that:


var mongoose = require('mongoose')
  , DataTable = require('mongoose-datatable');
DataTable.configure({ verbose: false, debug: false });
mongoose.plugin(DataTable.init);

Then all the mongoose model that you will declare will have access to the method dataTable.
eg.
In you controller that manage the users, you can respond to a dataTable client request like that:
(Using express as application)


function getDataTableUsers(req, res, next) {
  UserHelper.dataTable(req.query, function(err, data) {
    if (err) return next(err);
    res.send(data);
  });
}
app.get('/users/dataTable', getDataTableUsers);

All you need is to setup the dataTable plug-in on the clients side to fetch the needed information on the specified url.

I hope I answered your question, if not please feel free to ask more. If you want you can even send me example of your code for me to have a better view of what you are trying to do.

from mongoose-datatable.

jupe avatar jupe commented on September 10, 2024

Hi,
I've got the basic functionality to work, but searches not work at all some why. I've configured just same way as you mentioned. req.query is coming from DataTables ( bServerSide: true, sAjaxSource: "/myroute" )

I think my req.query is valid?

{ sEcho: '15',
  iColumns: '5',
  sColumns: '',
  iDisplayStart: '0',
  iDisplayLength: '50',
  mDataProp_0: 'function',
  mDataProp_1: 'function',
  mDataProp_2: 'function',
  mDataProp_3: 'function',
  mDataProp_4: 'function',
  sSearch: '',
  bRegex: 'false',
  sSearch_0: '',
  bRegex_0: 'false',
  bSearchable_0: 'true',
  sSearch_1: 'test',
  bRegex_1: 'false',
  bSearchable_1: 'true',
  sSearch_2: '',
  bRegex_2: 'false',
  bSearchable_2: 'true',
  sSearch_3: '123',
  bRegex_3: 'false',
  bSearchable_3: 'true',
  sSearch_4: '',
  bRegex_4: 'false',
  bSearchable_4: 'true',
  iSortCol_0: '0',
  sSortDir_0: 'asc',
  iSortingCols: '1',
  bSortable_0: 'true',
  bSortable_1: 'true',
  bSortable_2: 'true',
  bSortable_3: 'true',
  bSortable_4: 'true',
  sRangeSeparator: '~',
  _: '1367986051145' }

Is it possible that module can't find my schema paths? At least it looks little like that when I tried to debug a little. If I enable verbose flag, all searches just print:

Unmanaged condition on field type: undefined
Unmanaged condition on field type: undefined
Unmanaged condition on field type: undefined
Unmanaged condition on field type: undefined
Unmanaged condition on field type: undefined
Unmanaged condition on field type: undefined
Unmanaged condition on field type: undefined

I think it would be very helpful also for others if you could make a simple but complete example of the implementation..

I'm using these module versions:
[email protected]
[email protected]
[email protected] extraneous

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

Hi Jupe,

You are right, the module cannot find the fields you specified in the dataTable (aaColumns mData) in your mongoose model. In the request, the mDataProp_* fields should contain the name of the mongoose model fields you want to retrieve.

I have committed a light example using express 3.x and mongoose 3.x, it uses a small model tests with only 2 fields: str (String) and bool (Boolean). Since it is a basic setup of the mongoose-datable module, only the str field matches for the search and an info message is displayed for the bool field saying that conditions on Boolean field type is not managed.

I hope this example will be helpful regarding your issue. Please let me know.

from mongoose-datatable.

jupe avatar jupe commented on September 10, 2024

Thanks a lot. Problem was in my browser side DataTables initialization. I just add aoColumns array and everything work now. It might be good to add README usage section what requirements are in DataTable initialization side. By the way, there was couple bugs in your example -> package.json - jade missing, route "/datatable" works, but some why req.query parameters messed up maybe because there the public folder is a folder with the same name (datatable). This might be bug in expressjs ) .

from mongoose-datatable.

jupe avatar jupe commented on September 10, 2024

I recognized also that searching not work with older mongodb 1.8.x versions. That might be also good to be mentioned.

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

Ok thank you, I have updated the example: I added jade in the npm module list of the package file and rename /datatable by /data.

I will update the readme with the link to the datatable plug-in and the server side processing with some explanations. And add the version restriction of mongodb.

Thanks for your feedbacks, and if you need improvement or new feature feel free to contact me.

from mongoose-datatable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.