Page MenuHomeSealhub

value-not-existing-in-collection.js
No OneTemporary

value-not-existing-in-collection.js

const assert = require("assert");
module.exports = (app) => {
return {
name: "value-not-existing-in-collection",
extends: "value-existing-in-collection",
is_proper_value: async (context, params, new_value) => {
assert.equal(typeof params.field, "string");
assert(
typeof params.include_forbidden === "boolean" ||
params.include_forbidden === undefined
);
const collection = params.collection;
assert(collection instanceof app.Sealious.Collection);
await collection.fields[params.field].is_proper_value(
context,
new_value
);
if (params.include_forbidden) {
context = new app.Sealious.SuperContext();
}
const sealious_response = await app.run_action(
context,
["collections", collection.name],
"show",
{ filter: { [params.field]: new_value } }
);
if (!sealious_response.empty) {
return Promise.reject(
`Collection ${collection.name} already has a record with '${params.field}' set to '${new_value}'`
);
}
},
};
};

File Metadata

Mime Type
text/plain
Expires
Sat, Jun 7, 23:21 (2 m, 31 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
719662
Default Alt Text
value-not-existing-in-collection.js (1013 B)

Event Timeline