E
E
EgorLee2021-06-03 21:13:46
MongoDB
EgorLee, 2021-06-03 21:13:46

How to set non-zero array length condition in mongodb?

60b91b7c03007844976433.jpeg

I have such a document structure, I want to make a selection of documents where the length of the accounts array is not equal to 0, how can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Romanov, 2021-06-03
@EgorLee

It is possible like this: but it is not a fact that this is the best way
db.test.find({accounts:{$type: 4, $ne: []}})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question