Prepend to a collection using UPDATE
See original GitHub issueI can use UPDATE ADD to append to a collection field but what if I want to PREPEND to a collection to only get the last added element ?
UPDATE entries PREPEND myCollection = value
and then i can query
SELECT myCollection[0] FROM entries
to get sure to always query the last added element.
Is there a way to query for the last element of a collection in another way ?
Thank you for pieces of advice on this point.
Warmly, Robert
Issue Analytics
- State:
- Created 8 years ago
- Comments:23 (18 by maintainers)
Top Results From Across the Web
db.collection.update() — MongoDB Manual
Modifies an existing document or documents in a collection. The method can modify specific fields of an existing document or documents or replace...
Read more >prepend string to entire column in mongodb - Stack Overflow
You will need to retrieve, modify, and update each document. You can use the aggregation framework as explained in an answer below, but...
Read more >Inserting and updating — MongoDB Node.JS Driver 1.4.9 ...
To update and retrieve the contents for one single record you can use findAndModify. collection.findAndModify(criteria[, sort[, update[, options]]], callback).
Read more >How to Insert & Update MongoDB Documents - Studio 3T
Right-click on any cell while viewing a collection in Table, Tree, or JSON View.and choose Insert Document. Alternatively, use the shortcut Ctrl ...
Read more >MongoDB Python | Insert and Update Data - GeeksforGeeks
After insert to find the documents inside a collection we use find() command. The find() method issues a query to retrieve data from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi Ata,
Yes, you can also set the value on another field of course.
Thank you for the feedback about deprecating vs. dropping, let’s re-discuss it in next few weeks, after M1 is out.
Thanks
Luigi
Hi @Solido
I flagged this an an enhancement, it will be added to the roadmap
Thanks
Luigi