nezuo / lapis

A DataStore abstraction library for Roblox
https://nezuo.github.io/lapis/
MIT License
59 stars 10 forks source link

Implement a read-only mode #44

Closed Nidoxs closed 3 months ago

Nidoxs commented 7 months ago

It would be useful to have a way to read a player's data while they're not in the game. For example, if there's a leaderboard system where it shows the top 3 players on podiums and you want to show things they own like skins, guns etc. The read-only feature would allow you to load their data and hold it temporarily to extract the value(s) you need.

I believe ProfileService has a similar feature.

Thanks! 👍

nezuo commented 7 months ago

Thanks for the issue, Lapis should definitely have this feature!

jackTabsCode commented 6 months ago

Yeah, having a way to read data without imposing a session lock would be great!

nezuo commented 6 months ago

I've been thinking about this and I'm not sure how it should work with migrations. Would you expect this to return API to return data with an outdated migration version?

sasial-dev commented 6 months ago

Maybe it runs the migration code locally but doesn't save that data back?

sasial-dev commented 6 months ago

Either way feels like it's a 'gotcha' territory.

Nidoxs commented 6 months ago

Maybe it runs the migration code locally but doesn't save that data back?

I think applying a temporary unsaved migration is a necessary compromise for the proposed read-only mode.

I certainly don't have a use case for reading data that is out of date, so I think the natural step there is just running whatever migration is needed to bring the data up to date.

nezuo commented 6 months ago

Even if we did run the migration, you could have a situation where a server reads a document with a migration version higher than its own.

sasial-dev commented 5 months ago

That could still happen on it's normal write mode though? So I don't think it's in the scope of this issue?

nezuo commented 5 months ago

If you load a document that has a higher migration version than the servers, it will error and not load the document. We could do that here as well. I just don't know the specific use-cases people have for a read-only mode, so I don't know if that's acceptable.

jackTabsCode commented 5 months ago

I think it makes the most sense to return the data migrated to the version that the server calling it expects.

nezuo commented 5 months ago

I think it makes the most sense to return the data migrated to the version that the server calling it expects.

I agree, but if it is passed the server's migration version, you would expect it to error then?

jackTabsCode commented 5 months ago

I think it makes the most sense to return the data migrated to the version that the server calling it expects.

I agree, but if it is passed the server's migration version, you would expect it to error then?

Yes

nezuo commented 3 months ago

Resolved with #59.