Comments (6)
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.
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.
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.
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.
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.
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)
- Nested object search HOT 1
- mongoose-datatable-demo does not work with v1.0.4 HOT 2
- Column filtering/searching with regex HOT 8
- Nested object array search (Question) HOT 2
- Default Boolean handler not works for false value HOT 1
- Mongoose Queries HOT 10
- How to set conditions? HOT 1
- performance? HOT 1
- Unmanaged condition on field type: ObjectId HOT 3
- Can't get array data HOT 1
- Not working with __ttl document expiration via mongoose-ttl plugin HOT 2
- Date filtering HOT 5
- No data returned on mongoose 5 with options.conditions HOT 1
- search not working with populate data. HOT 1
- how to sort or order by date ('desc') HOT 1
- MongoDB uses non-optimal query indexes because of sort HOT 6
- Use aggregate with datatable HOT 1
- npm Installs Version 1.0.7 HOT 1
- Query lookup another collection, if not found still return HOT 1
- how to do subquery in formatter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-datatable.