MongoDB (+php) query
- or -
Post a project like this2482
£25(approx. $31)
- Posted:
- Proposals: 3
- Remote
- #1601661
- Awarded
Description
Experience Level: Intermediate
General information for the business: Backend data
Description of requirements/functionality: Just a single Mongo DB problem I can't figure out for which I will pay a fixed price for the answer:
In CollectionA I have documents owned by various users, signified by field.user_id
I need to limit the number of documents in CollectionA that are owned by a particular user to a fixed amount N, deleting older records to make way for newer ones.
Your job is to provide a query that will delete records matching user_id in reverse date_created order until N records remain.
I need the most efficient way to do this in Mongo, wrapped up in a php \MongoDB\Client example. The number of records we are talking about truncating is not huge (tens of thousands maximum); CollectionA could be millions of documents.
Specific technologies required: mongo
Extra notes:
Description of requirements/functionality: Just a single Mongo DB problem I can't figure out for which I will pay a fixed price for the answer:
In CollectionA I have documents owned by various users, signified by field.user_id
I need to limit the number of documents in CollectionA that are owned by a particular user to a fixed amount N, deleting older records to make way for newer ones.
Your job is to provide a query that will delete records matching user_id in reverse date_created order until N records remain.
I need the most efficient way to do this in Mongo, wrapped up in a php \MongoDB\Client example. The number of records we are talking about truncating is not huge (tens of thousands maximum); CollectionA could be millions of documents.
Specific technologies required: mongo
Extra notes:
Christopher W.
100% (21)Projects Completed
17
Freelancers worked with
17
Projects awarded
55%
Last project
19 May 2020
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies