UNPKG

sqlmongoose

Version:

Mongoose-like schemas and models for SQLite3

29 lines (28 loc) 1.02 kB
import 'reflect-metadata'; export var SchemaType; (function (SchemaType) { SchemaType["STRING"] = "string"; SchemaType["NUMBER"] = "number"; SchemaType["BOOLEAN"] = "boolean"; SchemaType["DATE"] = "date"; SchemaType["OBJECT"] = "object"; })(SchemaType || (SchemaType = {})); export function Entity(name) { return function (constructor) { Reflect.defineMetadata('entity:name', name, constructor); }; } export function Field(options) { return function (target, propertyKey) { const metadata = Reflect.getMetadata('fields', target.constructor) || {}; metadata[propertyKey] = options; Reflect.defineMetadata('fields', metadata, target.constructor); }; } export function Index(options = {}) { return function (target, propertyKey) { const metadata = Reflect.getMetadata('indices', target.constructor) || []; metadata.push({ field: propertyKey, ...options }); Reflect.defineMetadata('indices', metadata, target.constructor); }; }