Giter Site home page Giter Site logo

Order by query about domain-driven-hexagon HOT 2 CLOSED

sairyss avatar sairyss commented on May 12, 2024
Order by query

from domain-driven-hexagon.

Comments (2)

Sairyss avatar Sairyss commented on May 12, 2024

Hey

This interface is incorrect, I left it as number because I had some type overload issues and I forgot to fix it later.

TypeOrm interface looks like this:

    order?: {
        [P in keyof Entity]?: "ASC" | "DESC" | 1 | -1;
    };

Though interface is incorrect, it still works and you can order things. For example:

{ 
  params:{}, // some params here
  orderBy: { createdAt: -1 } 
}

^ This will order by createdAt DESC

from domain-driven-hexagon.

wiatrM avatar wiatrM commented on May 12, 2024

Unfortunetly your solution still gives me an error:

[backend] ERROR in src/modules/tkd/use-cases/crud/tkd.crud.services.ts:89:24
[backend] TS2322: Type '{ id: number; }' is not assignable to type 'OrderBy'.
[backend]   Object literal may only specify known properties, and 'id' does not exist in type 'OrderBy'.
[backend]     87 |                 skip: paginateDto?.offset
[backend]     88 |             },
[backend]   > 89 |             orderBy: { id : 1 }
[backend]        |                        ^^^^^^
[backend]     90 |         });
[backend]     91 |     }

Im not very good at TypeScript generic, could you write me how to change the interface to support ordering?

Thanks in advance

from domain-driven-hexagon.

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.