Reputation: 21
I started using rethinkDB. When I call up the elements of a table with getAll, the order of the table is unfortunately changed, for example: [6,2,4,5] -> [2,4,5,6]
How can I use getAll () without reshuffling "the cards"?
function* extract(next) {
const q = r
.db("darwin")
.table("roadbook")
.filter({ date: date })
.map((rb) => {
return {
//all: rb,
missionTickets: r
.db("darwin")
.table("missionOrderTicket")
.getAll(r.args(rb("missionTickets")))
.coerceTo("array"),
name: rb("missionTickets"),
shift: rb("description").default(""),
mateName: rb("meta")("summaries")("mateAlias").default(""),
radio: rb("radio").default(""),
};
});
return yield q.run(con, next);
}
greetings perry
Upvotes: 0
Views: 95
Reputation: 75
You cant use getAll
and get the documents with a specific order. You have to use the orderBy
function and order them by a field or by an index defined by you. In order to use the orderBy
function with an index you have to replace getAll
with between
as a trick because getAll
could not be chained with orderBy
on an index. But this will work only on a single value inside getAll
, not an array as in your case.
In your case where you have .getAll(r.args(rb("missionTickets")))
you can only order by an non-indexed key, or you should change your data model in order to use between
function and then orderBy
with a single value rather than r.args(rb("missionTickets"))
.
Upvotes: 0