vasern / vasern

Vasern is a fast, lightweight and open source data storage for React Native

Home Page:https://vasern.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

committed transaction list

apppro123 opened this issue · comments

I saw that there is a way to improve the speed of multiple actions.
Is it also faster if i don't commit these actions in a callback block but multiple single actions with save=false?
And if so, when do these actions get executed? (I mean how does the db know when i make the last action?)
I'm asking this because i have to add multiple events to the db. In one cycle i add to multiple schemas so i just want to call my "normal" saveEvent function (which normally just saves one event with save=true) with save=false. But is this faster?

Have you tried the perform block? It is somewhat similar to your idea and is designed to execute multiple operations (insert/update/remove).

Operations within the perform block will be called with save=false. When save=false, the record will be added to the commit transaction list, then later be executed by calling save() method.

Then i can call after the looped finished and so i made all the inserts with save=false the method save() and it saves all the inserts, removes or updates?
If so it is possible that you forgot to mention this on your vasern website (or maybe i just dont find it...).

Actually, setting save=false for any operation is intended for internal use only. So I consider not adding it to the documentation.

Do you think it would be more useful to set save=false rather than using with the “perform” block?

It’s kinda make sense for me now it can be more useful in some cases.

At the moment in my case i think it is useful because i have multiple refrences and so i have to insert for every loop session into multiple schemas and insert these results into the final schema.
I think if you have to loop and insert into multiple schemas and need the results it is useful and makes more sens then the perform() functions because otherwise you have perform( perform() perform()) or sth like that and that doesn't look nice.
In my opinion it makes sense to add this!

You’re right. It will be more useful in some cases. I’ll reconsider adding operation with “save=false” into the documentation

Thanks for the suggestion.

So it is not yet possible to insert with save=false and after loop to call save() ?

Yes, it is possible! Here is an example:

Items.insert({ name: “Item 1 }, false);
Items.insert({ name: “Item 2}, false)

// Apply changes
Items.save()

Perfekt!
Not related with that, but in this example you just wrote false instead of save=false. Is that possible?

It doesn’t need to actually have “save=fase”. Just “false” is correct.

I will close this issue since it has been resolved. Also, feel free to reopen or create a new one again