Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:09:01+00:00 2026-06-03T03:09:01+00:00

Desired behavior: In Clojure’s implementation of Agents, to update an Agent, one does NOT

  • 0

Desired behavior:

In Clojure’s implementation of Agents, to update an Agent, one does NOT send a new value. One sends a function, which is called on the old value, and the return value is set as the new value of the Agent.

This makes certain things easy: for example, if I have a queue, and I have two concurrent threads that both want to append to the queue (and I don’t care which order they append), each thread can just fire off a (fn [x] (cons x new_value)) … and it just works. Whereas, if it was updating by value, I’d have to do a compare and swap of some sort.

Question:

Is there any database that supports this type of updating? For example, I was recently looking at MongoDB. However, MongoDB supports only $inc/$dec, and not arbitrary functions for updating the documents.

Thanks!

PS — I don’t need transactions / ACID / BASE / … all I really want is a simple document store that supports updating via functions rather than values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:09:01+00:00Added an answer on June 3, 2026 at 3:09 am

    MongoDB actually supports multiple different modifier operations (full list here) and while I can see $inc/$dec alone might be limiting, a simple variant of specific example you give of adding to a queue could be handled using $push or $addToSet (depending on whether you wanted duplicates to appear in your queue or not as $addToSet will only add a value if it doesn’t already exist).

    For more complex cases (supporting compare and swap type of semantics) you can look at findAndModify command in MongoDB if you don’t find something simple that fits your needs exactly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my desired transaction order: User1 select field, perform operation, update with new
Desired behavior An undecorated non-nullable value-type property in a model automatically gets a validation
Example of failure: http://progamonth.com/files/testfile.html Desired Behavior: Ideally, any headers with a colspan shouldn't affect
Desired Behavior: After using the Like button on top of my fan page, I
I'm having trouble getting desired behavior in a WPF RichTextBox. I am creating a
The desired behavior is akin to the mirrored text editing field provided in Excel
I am having problems getting the desired behavior out of these few classes and
Desired Workflow First I wish to fetch a particular set of questions and answers
I have a client whose desired Web UI is graphically intense; we would like
Suppose I have the following (desired) folder structure: *CommonProject *Project#1 ----> CommonProject(link) *Project#2 ---->

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.