You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB
JavaScript

"use strict";
module.exports = {
migration: {
createCollection: [ operationCreateCollection, {
createField: operationCreateField,
createIndex: operationCreateIndex
}],
modifyCollection: {
createField: operationCreateField,
modifyField: operationModifyField,
deleteField: operationDeleteField,
createIndex: operationCreateIndex,
deleteIndex: operationDeleteIndex
},
deleteCollection: operationDeleteCollection
}
};
function operationCreateCollection(item) {
return {
type: "createCollection",
name: item.name
};
}
function operationDeleteCollection(item) {
return {
type: "deleteCollection",
name: item.name
};
// TODO: Actually make it delete the data? Maybe have an option in dev to retain 'deleted' collections? Need to figure out security/privacy implications of that, and whether it's even useful to begin with
}
function operationCreateField(item, path) {
return {
type: "createField",
collection: path.at(-1).name,
name: item.name,
operations: item.operations
};
}
function operationModifyField(item, path) {
return {
type: "modifyField",
collection: path.at(-1).name,
name: item.name,
operations: item.operations
};
}
function operationDeleteField(item, path) {
return {
type: "deleteField",
collection: path.at(-1).name,
name: item.name
};
}
function operationCreateIndex(_item, _path) {
throw new Error(`Not implemented yet`);
}
function operationDeleteIndex(_item, _path) {
throw new Error(`Not implemented yet`);
}