gadelkareem / sails-dynamodb

Amazon DynamoDB adapter for Waterline / Sails.js
http://sailsjs.org
46 stars 22 forks source link

Sort by UpdatedAt field not working #49

Closed ggarcia92 closed 6 years ago

ggarcia92 commented 6 years ago

I want to sort found elements by updatedAt field which is created and updated by default.

I have the following code:

Model:

  module.exports = {
      attributes: {
         id:{
            type: "string",
            primaryKey: 'hash'
         },
        title:{
            type: "string",
            required: true
        },
        category:{
            type: "string",
            required: true
        },
        subCategory:{
            type: "string"
        },
   }

Controller:

 Anuncio.find({
        where: {
            category: request.category,
            subCategory: request.subCategory
        },
        sort: "1"
    }).exec((err, result) => {
        if (err) return next(err);

        return res.json(result);
    });

This code don't sort properly.

I already tried to create the attribute updatedAt with an index and I get "Cannot read property 'dynamoType' of undefined".