Skip to content

Feature: orderBy/sort selectPromise method #584

@rallisf1

Description

@rallisf1

Is your feature request related to a problem?

Currently, the only way to apply ordering is to use a plain query().

Describe the solution

Add an orderBy(field: string, order: 'ASC'|'DESC' = 'ASC') method to selectPromise which generates an ORDER BY SQL clause internally.

Alternative methods

This would be a lot more work (in the surreal package as well) and might deserve its own feature request, but here it goes:

Add the ability to sort by a surreal function. Obviously, the function must pre-exist in the database. Then:

Add a sort(function: string) method to selectPromise which passes the whole query as an argument to the function and returns the function's result.

A lot of things can break this; so sorting functions could use their own UI form in Surrealist.

P.S. I don't really need sort(), maybe someone else does.

SurrealDB version

3.0.3 for linux on x86_64

JavaScript SDK version

2.0.2

Contact Details

rallisf1@yahoo.gr

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct (repository /surrealdb.js)

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions