Pinafore-Web-Client-Frontend/routes/_database/accountsAndRelationships.js

20 lines
892 B
JavaScript
Raw Normal View History

2018-02-09 07:04:10 +01:00
import { ACCOUNTS_STORE, RELATIONSHIPS_STORE } from './constants'
import { accountsCache, relationshipsCache } from './cache'
2018-02-14 04:34:37 +01:00
import { cloneForStorage, getGenericEntityWithId, setGenericEntityWithId } from './helpers'
2018-02-09 07:04:10 +01:00
2018-02-09 07:29:29 +01:00
export async function getAccount (instanceName, accountId) {
return getGenericEntityWithId(ACCOUNTS_STORE, accountsCache, instanceName, accountId)
2018-02-09 07:04:10 +01:00
}
2018-02-09 07:29:29 +01:00
export async function setAccount (instanceName, account) {
2018-02-14 04:34:37 +01:00
return setGenericEntityWithId(ACCOUNTS_STORE, accountsCache, instanceName, cloneForStorage(account))
2018-02-09 07:04:10 +01:00
}
2018-02-09 07:29:29 +01:00
export async function getRelationship (instanceName, accountId) {
return getGenericEntityWithId(RELATIONSHIPS_STORE, relationshipsCache, instanceName, accountId)
2018-02-09 07:04:10 +01:00
}
2018-02-09 07:29:29 +01:00
export async function setRelationship (instanceName, relationship) {
2018-02-14 04:34:37 +01:00
return setGenericEntityWithId(RELATIONSHIPS_STORE, relationshipsCache, instanceName, cloneForStorage(relationship))
2018-02-09 07:29:29 +01:00
}