Hi, I have a question as part of my Nakama explorations for our project and I don’t see a question like this already:
When performing operations on Storage Objects, is their internal implementation and storage using whichever database you have Nakama pointing to normally? (i.e. everything is saved in CockroachDB by default, but if you were pointing to postgresql, they both would live there)
If they are in the same “space”, can the internal data of storage objects ever be accessed outside of the Collection APIs in raw sql? (now SHOULD it be, might be a different question, since the developer might be trying to do something that is hinting on a change in the data model)
For example (this is just a rough example):
Player Inventory is stored as a collection, named “inventory”, indexed by “userid”, the json contents might contain a store catalogitemid with a count with other misc data.
A store catalog item might be stored as a SQL table “catalogitems”, indexed by “catalogitemid”.
A store might be stored as a SQL table “storecatalogitems”, indexed by “storecatalogitemid”, foreign key “catalogitemid”.
A query is needed to find out what items user 25 has in a store ID 2.
Can a join cross the “collection-SQL” boundary? Something like:
SELECT i.storageObjectId(?), ci.catalogitemid
FROM stores AS s
INNER JOIN catalogitems AS ci
ON s.catalogitemid = ci.catalogitemid
AND s.storeid = 2
INNER JOIN collectiontable_inventory AS i
ON ci.catalogitemid = {some kind of jsonb query looking inside for a matching i.catalogitemid}
AND i.UserId = 25
This specific example could probably be worked around in some client-side implementation that would get everything in a store and everything in the inventory for a player and finding matching IDs that way, but could mean sending potentially large data sets to the client unnecessarily.
Are they meant to remain separate data spaces? Server script can access both in separate statements, but I can imagine cases like the above you might want to access both via SQL.
Knowing this would help shape what kind of Data model is used for structures in Nakama.
thanks,
Barry