Update one Database-Collection based und values in another collection

Hi everybody,
I have just started using Appsmith and JS (coming from C-based programming, so I´m quite new to JS).
After struggling a bit with JS, I have managed to set up an App that reads Data from a MongoDB and writes changes to it. The app should be used to administrate workplaces and resources for our students. I have one collection for the students containing Names, information and the assigned workplaces and hardware and one for the workspaces (another for the hardware shall follow).
Now I have to update the occupied-flags of the Workplaces-collection (boolean) based on the selection in the Students-Collection.
I have a query for the selection-dropown that collects only unoccupied-flagged workplaces but I am completly lost how to update the flags by means of the used workplaces in the Students table.
Is there anyone with an idea how to solve this problem?
Normally I would generate an true/false array and use this to iterativly update the values in the workplaces collection but I can not tell how to do this in this enviroment or wether this is feasible.
I am thankful for any help.
Best regards


Ok, I have made some headway. I can get the IDs of the Collection I want to edit. But I can´t manage to update just one parameter of the Object in the MongoDB. Can anyone tell me the syntax how to do this?
I have a JS-Object that returns a list of IDs. At these IDs I want to chance the parameter “Occupied” to true or false. But I can´t get the Update Query to do so.
Thanks for all help.
Best regards.


Hello Marius and welcome to our community! Could you please share some screenshots of your code snippets and the error you get?

Hi Amelia,
thanks for the welcome.
I have written a JS-function that searches for objects where a the “Occupied-Parameter” is set to “true” (boolean).
This function called “Get_Used_WP_IDs” returns a list of object IDs

I want to use this list to set the Parameter “Occupied” to true for these Object-IDs.
But I can´t figure out the syntax for the Update-Query, because till now I haven´t fully understood it.
As I said I´m a beginner. Maybe the solution is quite easy.
I hope this helps to understand my problem.
Best regards


For testing I´m currently using a fixed ID (copy/paste from MongoDB) and
Collection: Arbeitsplätze

for Query:
{ _id: “637ccc886a7b584f66857484” }
Edit: Correct is :
{ _id: ObjectId(‘637ccc886a7b584f66857484’) }

For Update:

{ “$set”: { “Occupied”: true } }

The Output is:

“nModified”: 0

Edit: I sorted out the syntax for fixed IDs. Now I need to learn how to use Multiple IDs from the function output. Do I have to call the query one by one with one ID from JS or is it possible to directly update a list of IDs?

Best regards


Hi Marius! You can update multiple records by using ‘All Matching Documents’ as Limit. In your query, you can use the $in operator to update a list of IDs. Here is an example query:

Hi Amelia,

thank you for your help. I´m now able to manage these things :).

Yesterday we came up with the idea of visualizing time-spans where hardware resources are blocked oder reserved. I found out that appsmith is able to integrade google calender or calendly but we don´t want our calenders to be hosted externally. Is there a possibility to integrate a caldav/ical calender (as we are already hosting one on one of our servers). Or another way to show and analyze available resources?
Thank you for your help.
Best regards


Hi Marius,

Sure, you should be able to connect to iCal or Caldav, as they provide APIs. Basically, in Appsmith, you can connect to any REST API.