0

I am trying to sort a field, but I need to do it like how mysql does and specify the value,

instead of field number sory by -1, 4 3 2 1.

I need to sort it by 2,1,3,4.

is this possible in mongodb?

1 Answer 1

1

This is not possible in MongoDB. MongoDB doesn't know which and how many fields exist in a particular document unless the document is retrieved. Hence MongoDB practically cannot give numbers to specific fields.

MongoDB is a JSON-style data store. The documents stored in the database can have varying sets of fields, with different types for each field.

In Databases the number and types of the column is fixed by particular table definition and it's easier for a database system to give numbers to the columns.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.