pinia-orm
Version:
The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
34 lines (30 loc) • 902 B
JavaScript
import { v4 } from 'uuid';
import { C as CastAttribute } from '../shared/pinia-orm.C7bM_uXu.mjs';
import { o as ownMetadataRecord, c as createFieldDecorator, C as CASTS } from '../shared/pinia-orm.DhuaEUVi.mjs';
import '../shared/pinia-orm.pROBaphR.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 ?? v4(this.$parameters);
}
}
function Uid(options) {
return (_value, context) => {
ownMetadataRecord(context.metadata, CASTS)[String(context.name)] = UidCast.withParameters(options);
return createFieldDecorator((model) => model.uid())(_value, context);
};
}
export { Uid, UidCast };