@palmares/databases
Version:
Add support for working with databases with palmares framework
48 lines (46 loc) • 2.12 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/models/fields/exceptions.ts
var InvalidDefaultValueForFieldType = class extends Error {
static {
__name(this, "InvalidDefaultValueForFieldType");
}
constructor(fieldName, defaultValue, shouldBeOfType) {
super(`Invalid default value for field ${fieldName}: ${defaultValue}
Should be of type ${shouldBeOfType}`);
this.name = "InvalidDefaultValueForFieldType";
}
};
var ForeignKeyFieldRelatedOrRelationNameAlreadyExistsError = class extends Error {
static {
__name(this, "ForeignKeyFieldRelatedOrRelationNameAlreadyExistsError");
}
constructor(modelName, fieldName, relatedOrRelationName, otherFieldName, otherModelName, isRelatedName) {
super(`The ForeignKeyField with name '${fieldName}' on model '${modelName}' has a ${isRelatedName ? "relatedName" : "relationName"} '${relatedOrRelationName}' that already exists for the field '${otherFieldName}' on model '${otherModelName}'. Please, provide a different value.`);
this.name = "ForeignKeyFieldRelatedNameAlreadyExistsError";
}
};
var ForeignKeyFieldInvalidRelatedToError = class extends Error {
static {
__name(this, "ForeignKeyFieldInvalidRelatedToError");
}
constructor(fieldName, modelName) {
super(`Foreign key field ${fieldName} on model ${modelName} has invalid 'relatedTo' parameter. It should relate to a model, a function that returns a model or a string`);
this.name = "ForeignKeyFieldInvalidRelatedToError";
}
};
var ForeignKeyFieldRequiredParamsMissingError = class extends Error {
static {
__name(this, "ForeignKeyFieldRequiredParamsMissingError");
}
constructor(fieldName) {
super(`Foreign key field ${fieldName} requires a reference to a model with 'relatedTo' and 'onDelete' parameter`);
this.name = "ForeignKeyFieldRequiredParamsMissingError";
}
};
export {
ForeignKeyFieldInvalidRelatedToError,
ForeignKeyFieldRelatedOrRelationNameAlreadyExistsError,
ForeignKeyFieldRequiredParamsMissingError,
InvalidDefaultValueForFieldType
};