mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-25 23:58:02 +03:00
41 lines
897 B
TypeScript
41 lines
897 B
TypeScript
import {Realm} from "realm";
|
|
|
|
export interface AMCardData {
|
|
code: string;
|
|
name: string;
|
|
|
|
added: Date;
|
|
lastUsed?: Date | null;
|
|
}
|
|
|
|
export class AMCard extends Realm.Object<AMCard> implements AMCardData {
|
|
_id!: Realm.BSON.ObjectId;
|
|
|
|
code: string;
|
|
name: string;
|
|
|
|
added: Date;
|
|
lastUsed?: Date | null;
|
|
|
|
static generate(code: string, name: string) {
|
|
return {
|
|
_id: new Realm.BSON.ObjectId(),
|
|
code: code,
|
|
name: name,
|
|
added: new Date()
|
|
};
|
|
}
|
|
|
|
static schema: Realm.ObjectSchema = {
|
|
name: "card",
|
|
primaryKey: "_id",
|
|
|
|
properties: {
|
|
_id: "objectId",
|
|
code: "string",
|
|
name: {type: "string", default: "New Card"},
|
|
added: {type: "date", default: new Date()},
|
|
lastUsed: {type: "date", optional: true}
|
|
}
|
|
};
|
|
} |