store
Types from PocketBase's Go package store, as JavaScript sees them: you get these objects from $app and the other globals and from hook events, and call their methods by their JS names (Go's FindRecordById is findRecordById). The same package in Go: store.
store.Store
Store defines a concurrent safe in memory key-value data store.
| Member | Type | |
|---|---|---|
reset() |
(newData: { [key: string]: any }): void |
Reset clears the store and replaces the store data with a shallow copy of the provided newData. |
length() |
(): number |
Length returns the current number of elements in the store. |
removeAll() |
(): void |
RemoveAll removes all the existing store entries. |
remove() |
(key: K): void |
Remove removes a single entry from the store. |
has() |
(key: K): boolean |
Has checks if element with the specified key exist or not. |
get() |
(key: K): T |
Get returns a single element value from the store. |
getOk() |
(key: K): [T, boolean] |
GetOk is similar to Get but returns also a boolean indicating whether the key exists or not. |
getAll() |
(): { [key: string]: any } |
GetAll returns a shallow copy of the current store data. |
keys() |
(): Array<K> |
Keys returns a slice with all of the store keys. |
values() |
(): Array<T> |
Values returns a slice with all of the store values. |
set() |
(key: K, value: T): void |
Set sets (or overwrite if already exists) a new value for key. |
setFunc() |
(key: K, fn: (old: T) => T): void |
SetFunc sets (or overwrite if already exists) a new value resolved from the function callback for the provided key. |
getOrSet() |
(key: K, setFunc: () => T): T |
GetOrSet retrieves a single existing value for the provided key or stores a new one if it doesn't exist. |
setIfLessThanLimit() |
(key: K, value: T, maxAllowedElements: number): boolean |
SetIfLessThanLimit sets (or overwrite if already exist) a new value for key. |
unmarshalJSON() |
(data: string|Array<number>): void |
UnmarshalJSON implements json.unmarshaler and imports the provided JSON data into the store. |
marshalJSON() |
(): string|Array<number> |
MarshalJSON implements json.marshaler and export the current store data into valid JSON. |
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.