budibase/initialise/createInstanceDb.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-06-07 13:02:48 +02:00
const {common, getAppApis} = require("budibase-core");
const {getDatabaseManager} = require("./helpers");
module.exports = async (productSetId, productId, versionId) => {
const databaseManager = getDatabaseManager(datastoreModule);
const masterDatastore = datastoreModule.getDatastore(
databaseManager.masterDatastoreConfig
);
const master = await getAppApis(masterDatastore);
const productSet = await master.recordApi.load(
common.joinKey("ProductSets", productSetId)
);
const prodcutSetDatastore = datastoreModule.getDatastore(
productSet.datastoreConfig
);
const productSetApis = await getAppApis(prodcutSetDatastore);
const product = await productSetApis.recordApi.load(
common.joinKey("Products", productId)
);
const version = await productSetApis.recordApi.load(
common.joinKey("Products", productId, "Versions", versionId)
);
const instance = await productSetApis.recordApi.getNew(
common.joinKey(product.key, "Versions", )
);
2019-04-05 17:30:29 +02:00
}