question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prepend to a collection using UPDATE

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:23 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
luigidellaquilacommented, Mar 28, 2017

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

1reaction
luigidellaquilacommented, Jan 7, 2016

Hi @Solido

I flagged this an an enhancement, it will be added to the roadmap

Thanks

Luigi

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found