Giter VIP home page Giter VIP logo

Comments (3)

eherve avatar eherve commented on September 10, 2024

Hello,

Thanks for using the module.
Can you give me the models for me to test ?

Regards,

from mongoose-datatable.

dragospanoiu avatar dragospanoiu commented on September 10, 2024

Hey,

I just changed a bit your demo project, I added a second model, looks like this:

// user model
usersSchema = new Schema(
{
  name : String
});
mongoose.model('User', usersSchema);
UModel = require('mongoose').model('User');

// reservation model
reservationsSchema = new Schema(
{
  name : String,
  startDate : String,
  endDate : {type: Schema.Types.ObjectId, ref: 'User'},
  confirmationCode : String
});
mongoose.model('reservations', reservationsSchema);
MyModel = require('mongoose').model('reservations');

And on the frontened I've changed the columns in the table like this:

"aoColumns" : [
    { "mData" : "name" },
    { "mData" : "startDate" },
    { "mData" : "endDate.name" },
    { "mData" : "confirmationCode" }
  ]

Whenever I try to sort by the endDate column is not working, although the query in populate says that is sorted by the name column in User model:

populate:
   [ { path: 'username',
       sort: { name: 'asc' },
       select: 'name' } ] }

Am I doing something wrong?

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

Hi,

Sorry for the late reply !
The population in mongodb is done after the fetch of the root document. So it is not possible to sort by populated data.
The sort in populate just sort the array of populated elements.

Regards

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.