pinia-orm
Version:
The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
33 lines (29 loc) • 721 B
JavaScript
import { v1 } from 'uuid';
import { C as CastAttribute } from '../shared/pinia-orm.C7bM_uXu.mjs';
class UidCast extends CastAttribute {
static parameters;
/**
* Create a new String attribute instance.
*/
constructor(attributes) {
super(attributes);
}
static withParameters(parameters) {
this.parameters = parameters;
return this;
}
/**
* Make the value for the attribute.
*/
set(value) {
return value ?? v1(this.$parameters);
}
}
function Uid(options) {
return (target, propertyKey) => {
const self = target.$self();
self.setCast(propertyKey, UidCast.withParameters(options));
self.setRegistry(propertyKey, () => self.uid());
};
}
export { Uid, UidCast };