59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { Realm } from '@realm/react';
|
|
import { Tag } from './tag';
|
|
|
|
enum MEME_TYPE {
|
|
IMAGE = 'Image',
|
|
GIF = 'GIF',
|
|
VIDEO = 'Video',
|
|
AUDIO = 'Audio',
|
|
ALBUM = 'Album',
|
|
TEXT = 'Text',
|
|
}
|
|
|
|
const memeTypePlural = {
|
|
[MEME_TYPE.IMAGE]: 'Images',
|
|
[MEME_TYPE.GIF]: 'GIFs',
|
|
[MEME_TYPE.VIDEO]: 'Videos',
|
|
[MEME_TYPE.AUDIO]: 'Audio',
|
|
[MEME_TYPE.ALBUM]: 'Albums',
|
|
[MEME_TYPE.TEXT]: 'Text',
|
|
};
|
|
|
|
class Meme extends Realm.Object<Meme> {
|
|
id!: Realm.BSON.UUID;
|
|
type!: MEME_TYPE;
|
|
uri!: Realm.List<string>;
|
|
size!: number;
|
|
title!: string;
|
|
description?: string;
|
|
isFavorite!: boolean;
|
|
tags!: Realm.List<Tag>;
|
|
tagsLength!: number;
|
|
dateCreated!: Date;
|
|
dateModified!: Date;
|
|
dateUsed?: Date;
|
|
timesUsed!: number;
|
|
|
|
static schema: Realm.ObjectSchema = {
|
|
name: 'Meme',
|
|
primaryKey: 'id',
|
|
properties: {
|
|
id: 'uuid',
|
|
type: { type: 'string', indexed: true },
|
|
uri: 'string[]',
|
|
size: 'int',
|
|
title: 'string',
|
|
description: 'string?',
|
|
isFavorite: { type: 'bool', indexed: true, default: false },
|
|
tags: 'Tag[]',
|
|
tagsLength: { type: 'int', default: 0 },
|
|
dateCreated: { type: 'date', default: new Date() },
|
|
dateModified: { type: 'date', default: new Date() },
|
|
dateUsed: 'date?',
|
|
timesUsed: { type: 'int', default: 0 },
|
|
},
|
|
};
|
|
}
|
|
|
|
export { MEME_TYPE, memeTypePlural, Meme };
|