import { getFamily, put } from './lib'; import getUri from '../lib/ids'; export const initialAccount = { id: 'initial', name: '???', localDb: 'dyomedea', }; export const getAccounts = async () => { const accountDocs = await getFamily('account', { include_docs: true }, true); return accountDocs.rows.map((row: any) => row.doc.doc); }; export const putAccount = async (id: string, account: any) => { const uri = getUri('account', { account: id }); return await put(uri, 'account', (_: any) => account, {}, true); }; export const getAccountById = (accounts: any, id: string) => { const targetAccounts: any[] = accounts.filter((acc: any) => acc.id === id); return targetAccounts[0]; };