({
context,
data,
initList = defaultInitList
}: InitDbCacheProps)
| 49 | } |
| 50 | |
| 51 | export const initDbCache = async ({ |
| 52 | context, |
| 53 | data, |
| 54 | initList = defaultInitList |
| 55 | }: InitDbCacheProps) => { |
| 56 | console.log(`// Initializing db cache… (${initList.join()})`) |
| 57 | const { surveys, entities } = data |
| 58 | if (initList.includes('entities')) { |
| 59 | const { entities } = data |
| 60 | for (let e of entities) { |
| 61 | e = await applyEntityResolvers(e, context) |
| 62 | } |
| 63 | await cacheSurveysEntities({ |
| 64 | surveys, |
| 65 | entities, |
| 66 | context |
| 67 | }) |
| 68 | } |
| 69 | if (initList.includes('surveys')) { |
| 70 | await cacheSurveys({ |
| 71 | surveys, |
| 72 | context |
| 73 | }) |
| 74 | } |
| 75 | if (initList.includes('projects')) { |
| 76 | await initProjects({ context }) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | export const reinitialize = async ({ context, initList = defaultInitList }: InitProps) => { |
| 81 | const data = await initMemoryCache({ context, initList }) |
nothing calls this directly
no test coverage detected