budibase/packages/server/utilities/createInstanceDb.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-06-07 13:02:48 +02:00
const {common, getAppApis} = require("budibase-core");
2019-06-14 11:05:46 +02:00
const {getDatabaseManager} = require("./databaseManager");
2019-06-07 13:02:48 +02:00
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
}