pinafore/routes/_database/accountsAndRelationships.js

20 lines
892 B
JavaScript
Raw Normal View History

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