You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to budibase. I have read the documentation and also doing some testing on my own trying to learn how does the platform works. In oder to learn how it works I am trying to build a simple Inventory application using budibase internal data storage that as I understand uses CoachDb.
I have encounter a problem that I am not able to solve. I have a table called Stock where I keep track of the quantity of each article. Let's say that this table has two columns: ArticleID and Quantity.
I have a form that lets me update the Quantity of an specific Article. The thing is that if I have two users working at the same time on that form and one updates one entry, the other one is not warned about the update and can update again the same entry with another value.
I read about how to solve this issue in CouchDB and found out that each entry has a _rev column that can help me to solve this issue. The general idea would be:
I read the content of the entry, including the _rev value.
I update the same entry sending in the update request the _rev value that I got in step 1.
The couchdb would check if the _rev that I send in my update request is the same that the one is actually on the table (if other user update the table between my steps 1 and 2 it would be different). If the _rev values do not match the update request would fail , in the case the are the same the update request will succedded.
I tried to implement this behaviour in budibase in the following way:
I have a database provider that queries the table.
I have a table component that takes the information of the databaseprovider and show me a table with the values.
Each row of the table in the GUI has also a button that when click does the following:
3.1 Saves in a new state the value of the _rev of the clicked row and also the _id.
3.2 opens a side panel.
This side panel includes a databaseprovider that filters the entries using the _id saved in the state and thens has a form block that takes the row that cames out from the dataprovider and show a form with it contents.
After editing the values of the form there is a button called "update" that when is clicked it calls the "Save Row" action. I edit this action so it also saves the _rev value using the value that i had previously store in the _rev state variable. Here I am assuming that in the request send to the coachdb this additional field would be included.
I have tried the following case:
I open two browser. In the first one I logged in as User1 and in the second one as User2.
Using User1, I access the GUI table and open the side panel to edit a row that contains the information for the ArticleID = 1
Using User2, I access the GUI table and open the side panel to edit a row that contains the information for the ArticleID = 1
In both browsers I see the same information for the row.
Using User1, I edit the row content and click the "update" button. This updates the entry in the couchdb and acording to what I have read also the _rev value of that entry.
Now using User2, I also edit the row (I did not refresh so what I am seeing is the old value) and click the "update" button. As in the action "Save row" I had manually added the field _rev so to be updated with the value that I got when I read the row and that value is now different in the databse because User1 has changed it with his update I expect that this second update fails but I does not. The row is update whith the new value overwritting the one the User1 changed.
It is like the _rev value that I am including in the "Save Row" action is not working as expected.
¿Can anybody give me a hint about what can be happening or how can I solve this concurrency update problem in other way using the internal budibase table?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am new to budibase. I have read the documentation and also doing some testing on my own trying to learn how does the platform works. In oder to learn how it works I am trying to build a simple Inventory application using budibase internal data storage that as I understand uses CoachDb.
I have encounter a problem that I am not able to solve. I have a table called Stock where I keep track of the quantity of each article. Let's say that this table has two columns: ArticleID and Quantity.
I have a form that lets me update the Quantity of an specific Article. The thing is that if I have two users working at the same time on that form and one updates one entry, the other one is not warned about the update and can update again the same entry with another value.
I read about how to solve this issue in CouchDB and found out that each entry has a _rev column that can help me to solve this issue. The general idea would be:
I tried to implement this behaviour in budibase in the following way:
3.1 Saves in a new state the value of the _rev of the clicked row and also the _id.
3.2 opens a side panel.
I have tried the following case:
It is like the _rev value that I am including in the "Save Row" action is not working as expected.
¿Can anybody give me a hint about what can be happening or how can I solve this concurrency update problem in other way using the internal budibase table?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions