Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add limit in find function in mongo_api call #260

Open
shiva6318 opened this issue Feb 7, 2024 · 0 comments
Open

How to add limit in find function in mongo_api call #260

shiva6318 opened this issue Feb 7, 2024 · 0 comments

Comments

@shiva6318
Copy link

Hi,

iam trying to get only two documents from mongodb using mongo_api:find/4 by adding limit to get the result but it is not working.

Key = #{<<"$query">> => #{<<"asset_id">> => Device_id,<<"packet_type">> => #{<<"$in">> => [<<"live">>,<<"historymod">>]},<<"packet_time">> => #{<<"$lte">> => PacketTime}},<<"$limit">> => #{<<"limit">> => 2},<<"$orderby">> => #{<<"packet_time">> => -1}},
mongo_api:find(hhd_mongopool_v2,?COLLECTION_TRACK, Key, #{}).

i have tried all possible way to add limit some are show below

  1. <<"$limit">> => #{<<"limit">> => 2}
  2. #{<<"limit">> => 2}
  3. #{<<"$limit">> => 2}
  4. <<"$limit">> => 2
  5. <<"limit">> => 2

i have tried to use batchsize also but not working . can anyone please help in this query to add limit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant