Giter VIP home page Giter VIP logo

Comments (10)

eherve avatar eherve commented on September 10, 2024

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.

Fonz001 avatar Fonz001 commented on September 10, 2024

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.

eherve avatar eherve commented on September 10, 2024

Ok can you give me the debug trace please

from mongoose-datatable.

Fonz001 avatar Fonz001 commented on September 10, 2024

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:

  1. (clone repo)
  2. npm install
  3. node bin/db-seed.js (assuming you have a local mongodb installation)
  4. node bin/www
  5. 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:

  1. This problem still needs some sort of fix
  2. A quick fix is to not specify a field but an object (see working/failing case)
  3. 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.

Fonz001 avatar Fonz001 commented on September 10, 2024

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.

eherve avatar eherve commented on September 10, 2024

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.

Fonz001 avatar Fonz001 commented on September 10, 2024

Both of the cases fail indeed.

Thank you for your time!

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

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.

Fonz001 avatar Fonz001 commented on September 10, 2024

Thanks! Great that you took your time to solve the issue!

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

Version 1.0.4 solve the deep populqtion

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.