Returns true if the given key is present in the storage.
storage.contains("myKey")
The unique identifier associated with a value in a key-value store
True if the given key is present in the storage.
Deletes a given key from the storage.
storage.delete("myKey")
The unique identifier associated with a value in a key-value store
Gets given generic value stored under the key. Key is encoded as UTF-8 strings.
Supported types: string and data objects defined in model.ts.
Please use getPrimitive
storage.get<string>("myKey")
storage.get<u16>("myKey")
storage.get<MyCustomObject>("myKey")
The unique identifier associated with a value in a key-value store
The default value if the key is not available
A value of type T stored under the given key.
Get byte array stored under given key. Key is encoded as UTF-8 strings. Byte array stored as is.
It's convenient to use this together with DomainObject.decode()
.
storage.getBytes("myKey")
The unique identifier associated with a value in a key-value store
Byte array stored under given key
Gets given generic value stored under the key. Key is encoded as UTF-8 strings. Supported types: bool, integer.
This function will throw if type T can not be cast as integer
storage.getPrimitive<string>("myKey", "default value")
storage.getPrimitive<u16>("myKey", 123)
The unique identifier associated with a value in a key-value store
The default value if the key is not available
A value of type T stored under the given key.
Gets given generic value stored under the key. Key is encoded as UTF-8 strings. Supported types: bool, integer, string and data objects defined in model.ts.
This function will throw if the key does not exist in the storage.
storage.getSome<string>("myKey")
storage.getSome<u16>("myKey")
The unique identifier associated with a value in a key-value store
A value of type T stored under the given key.
Get string value stored under given key. Both key and value are encoded as UTF-8 strings.
let value = storage.getString("myKey")
The unique identifier associated with a value in a key-value store
String value stored under given key
Returns true if the given key is present in the storage.
// alias for method contains()
The unique identifier associated with a value in a key-value store
True if the given key is present in the storage.
Stores given generic value under the key. Key is encoded as UTF-8 strings. Supported types: bool, integer, string and data objects defined in model.ts.
storage.set<string>("myKey", "myValue")
storage.set<u16>("myKey", 123)
storage.set<MyCustomObject>("myKey", new MyCustomObject())
The unique identifier associated with a value in a key-value store
The value stored at a particular key in a key-value store
Store byte array under given key. Key is encoded as UTF-8 strings. Byte array stored as is.
It's convenient to use this together with domainObject.encode()
.
let data = new Uint8Array([1,2,3])
storage.setBytes("myKey", data)
The unique identifier associated with a value in a key-value store
The value stored at a particular key in a key-value store
Store string value under given key. Both key and value are encoded as UTF-8 strings.
storage.setString("myKey", "myValue")
The unique identifier associated with a value in a key-value store
The value stored at a particular key in a key-value store
Generated using TypeDoc
This class represents contract storage.
It is a key-value store that is persisted on the NEAR blockchain.