Hi there,
I am trying to set up data on the Nakama runtime start up by following this tutorial, but I am getting the error
Storage write rejected - version check failed
when calling
nk.storageWrite(<writeObjects>)
My code looks as such, where TREASURES
is a list of my Treasure
class defined elsewhere:
const writeObjects: nkruntime.StorageWriteRequest[] =
TREASURES
.map(treasure => {
// create a write request object for each Treasure
const writeRequest: nkruntime.StorageWriteRequest = {
userId: "00000000-0000-0000-0000-000000000000",
collection: TREASURES_COLLECTION_NAME,
key: `${treasure.treasureId}`,
permissionRead: TREASURES_PERMISSION_READ,
permissionWrite: TREASURES_PERMISSION_WRITE,
value: treasure,
};
return writeRequest;
});
try {
nk.storageWrite([...writeObjects]);
} catch (error) {
logger.error('Treasures storageWrite error: %q', error);
throw error;
}
I saw a previous post where it was suggested to take out the version
attribute from the nkruntime.StorageWriteRequest
, but as you can see from my snippet, I do not have the optional version
attribute on my request objects
I would like to be able to do version: "*"
, as it says in the documentation that it will only create a storage object if it does not exist in the database - which is what I truly want.
How can I
- write objects to the database in this manner
- use the
version: "*"
attribute in my storage write request object to only create these game artifacts once?
Any help is welcome and appreciated.
Thank you!
- Versions: Nakama
3.10.0
, Docker, Unity 2021.1.11f - Server Framework Runtime language: TS/JS
- Cockroach DB image version:
cockroachdb/cockroach:latest-v21.2