Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
797 B

import { isShardedIndex } from "../templateApi/hierarchy"
import { joinKey } from "../common"
import {
getShardMapKey,
getUnshardedIndexDataKey,
createIndexFile,
} from "./sharding"
export const initialiseIndex = async (datastore, dir, index) => {
const indexDir = joinKey(dir, index.name)
let newDir = false
if (!await datastore.exists(indexDir)) {
await datastore.createFolder(indexDir)
newDir = true
}
if (isShardedIndex(index)) {
const shardFile = getShardMapKey(indexDir)
if (newDir || !await datastore.exists(shardFile))
await datastore.createFile(shardFile, "[]")
} else {
const indexFile = getUnshardedIndexDataKey(indexDir)
if (newDir || !await datastore.exists(indexFile))
await createIndexFile(datastore, indexFile, index)
}
}