Comments (10)
Hi,
Thank you for using this module.
Did you try to specify the field you need instead of just the manufactor ?
Like: product.manufactor.name or something like that ?
Regards
from mongoose-datatable.
Hi!
That doesnt help. It says: PATH_SEPARATOR not found.
Replacing PATH_SEPARATOR for "." doesn't help either. The field is not populated (the objectId is still there)
Greetings!
from mongoose-datatable.
Ok can you give me the debug trace please
from mongoose-datatable.
Hi!
I got it figured out; However, I'm working with company sensitive data, so I had to create a fresh project just to solve this bug. See: https://github.com/Fonz001/mongoose-datatables-test
Installation:
- (clone repo)
- npm install
- node bin/db-seed.js (assuming you have a local mongodb installation)
- node bin/www
- goto: http://localhost:3000/
The crucial part how I got it to work is located in: view/index.jade:
This works
{"mData": "name"},
{"mData": "product"},
{"mData": "product.manufacturer.name"}
This fails:
{"mData": "name"},
{"mData": "product.name"},
{"mData": "product.manufacturer.name"}
Now for the debug info during the fail:
Query: { draw: '1',
columns:
[ { data: 'name',
name: '',
searchable: 'true',
orderable: 'true',
search: [Object] },
{ data: 'product.name',
name: '',
searchable: 'true',
orderable: 'true',
search: [Object] },
{ data: 'product.manufacturer.name',
name: '',
searchable: 'true',
orderable: 'true',
search: [Object] } ],
order: [ { column: '0', dir: 'asc' } ],
start: '0',
length: '10',
search: { value: '', regex: 'false' },
_: '1437507698573' }
Search Criteria builded: { options: {},
pageStart: 0,
pageSize: 10,
nbColumns: 3,
search: undefined,
fields:
[ { index: 0,
path: 'name',
searchable: true,
search: undefined,
sortable: true,
sort: { dir: 'asc', precedence: 0 },
selectable: true,
type: 'String',
ref: undefined,
refType: undefined,
arrayType: undefined,
base: undefined,
arrayPath: undefined },
{ index: 1,
path: 'product.name',
searchable: true,
search: undefined,
sortable: true,
sort: undefined,
selectable: true,
type: 'String',
ref: undefined,
refType: undefined,
arrayType: undefined,
base: [ 'product' ],
arrayPath: undefined },
{ index: 2,
path: 'product.manufacturer.name',
searchable: true,
search: undefined,
sortable: true,
sort: undefined,
selectable: true,
type: 'String',
ref: undefined,
refType: undefined,
arrayType: undefined,
base: [ 'product', 'manufacturer' ],
arrayPath: undefined } ],
select: { name: 1, product: 1 },
sort: { name: 'asc' },
conditions: undefined,
populate:
[ { path: 'product', sort: {}, select: 'name' },
{ path: 'product.manufacturer', sort: {}, select: 'name' } ] }
Data: { draw: '1',
recordsTotal: 4,
recordsFiltered: 4,
data:
[ { _id: 55ae9ebd60da88e82766f159,
name: 'Item 1',
product: { _id: 55ae9ebd60da88e82766f156, name: 'Product 1' } },
{ _id: 55ae9ebd60da88e82766f15a,
name: 'Item 2',
product: { _id: 55ae9ebd60da88e82766f156, name: 'Product 1' } },
{ _id: 55ae9ebd60da88e82766f15b,
name: 'Item 3',
product: { _id: 55ae9ebd60da88e82766f157, name: 'Product 2' } },
{ _id: 55ae9ebd60da88e82766f15c,
name: 'Item 4',
product: { _id: 55ae9ebd60da88e82766f158, name: 'Product 3' } } ] }
Conclusions:
- This problem still needs some sort of fix
- A quick fix is to not specify a field but an object (see working/failing case)
- I replaced the PATH_SEPARATOR for "." (temporary fix)
And finally, since you are already digging into the code. Do you have any suggestions what a better implementation might be? Note that I need the object_id for link to the item/product/manufacturer.
Greetings,
Patrick
from mongoose-datatable.
I apologise! It seems that the test case from above is not a quick fix. I had 2 node servers running by accident...
Still, the project can easily be used for debugging.
The settings:
"aoColumns": [
{"mData": "name"},
{"mData": "product.name"},
{"mData": "product.manufacturer.name"}
],
The debug trace:
Query: { draw: '1',
columns:
[ { data: 'name',
name: '',
searchable: 'true',
orderable: 'true',
search: [Object] },
{ data: 'product.name',
name: '',
searchable: 'true',
orderable: 'true',
search: [Object] },
{ data: 'product.manufacturer.name',
name: '',
searchable: 'true',
orderable: 'true',
search: [Object] } ],
order: [ { column: '0', dir: 'asc' } ],
start: '0',
length: '10',
search: { value: '', regex: 'false' },
_: '1437551971756' }
Search Criteria builded: { options: {},
pageStart: 0,
pageSize: 10,
nbColumns: 3,
search: undefined,
fields:
[ { index: 0,
path: 'name',
searchable: true,
search: undefined,
sortable: true,
sort: { dir: 'asc', precedence: 0 },
selectable: true,
type: 'String',
ref: undefined,
refType: undefined,
arrayType: undefined,
base: undefined,
arrayPath: undefined },
{ index: 1,
path: 'product.name',
searchable: true,
search: undefined,
sortable: true,
sort: undefined,
selectable: true,
type: 'String',
ref: undefined,
refType: undefined,
arrayType: undefined,
base: [ 'product' ],
arrayPath: undefined },
{ index: 2,
path: 'product.manufacturer.name',
searchable: true,
search: undefined,
sortable: true,
sort: undefined,
selectable: true,
type: 'String',
ref: undefined,
refType: undefined,
arrayType: undefined,
base: [ 'product', 'manufacturer' ],
arrayPath: undefined } ],
select: { name: 1, product: 1 },
sort: { name: 'asc' },
conditions: undefined,
populate:
[ { path: 'product', sort: {}, select: 'name' },
{ path: 'product.manufacturer', sort: {}, select: 'name' } ] }
Data: { draw: '1',
recordsTotal: 4,
recordsFiltered: 4,
data:
[ { _id: 55ae9ebd60da88e82766f159,
name: 'Item 1',
product: { _id: 55ae9ebd60da88e82766f156, name: 'Product 1' } },
{ _id: 55ae9ebd60da88e82766f15a,
name: 'Item 2',
product: { _id: 55ae9ebd60da88e82766f156, name: 'Product 1' } },
{ _id: 55ae9ebd60da88e82766f15b,
name: 'Item 3',
product: { _id: 55ae9ebd60da88e82766f157, name: 'Product 2' } },
{ _id: 55ae9ebd60da88e82766f15c,
name: 'Item 4',
product: { _id: 55ae9ebd60da88e82766f158, name: 'Product 3' } } ] }
from mongoose-datatable.
Hi,
Thanks for the trace, so both cases are not working ?
The debug shows that the populate should have been done... I'll try tonight to see what is the request that is send to the database.
from mongoose-datatable.
Both of the cases fail indeed.
Thank you for your time!
from mongoose-datatable.
I have pushed a solution for deep populate but I have to test it more and add one more feature before releasing it.
This version does the deep populate but you need to request all intermediate fields. I'm adding the auto intermediate fields request for the release.
Now
1.0.3a"aoColumns": [ {"mData": "name"}, {"mData": "product.name"}, {"mData": "product.manufacturer"}, {"mData": "product.manufacturer.name"} ],
Next
1.0.3"aoColumns": [ {"mData": "name"}, {"mData": "product.name"}, {"mData": "product.manufacturer.name"} ],
from mongoose-datatable.
Thanks! Great that you took your time to solve the issue!
from mongoose-datatable.
Version 1.0.4 solve the deep populqtion
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.