Add Realm base

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-08 19:07:31 +03:00
parent 3cdf3c2295
commit c1c22145b2
7 changed files with 103 additions and 30 deletions

45
src/database/meme.ts Normal file
View File

@@ -0,0 +1,45 @@
import { Realm } from '@realm/react';
import { Tag } from './tag';
enum MEME_TYPE {
IMAGE = 'IMAGE',
GIF = 'GIF',
ALMBUM = 'ALMBUM',
VIDEO = 'VIDEO',
AUDIO = 'AUDIO',
TEXT = 'TEXT',
}
class Meme extends Realm.Object<Meme> {
id!: Realm.BSON.UUID;
type!: MEME_TYPE;
uri!: string;
title!: string;
description?: string;
isFavorite!: boolean;
tags!: Realm.List<Tag>;
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',
title: 'string',
description: 'string?',
isFavorite: { type: 'bool', indexed: true, default: false },
tags: 'Tag[]',
dateCreated: 'date',
dateModified: 'date',
dateUsed: 'date?',
timesUsed: { type: 'int', default: 0 },
},
};
}
export { MEME_TYPE, Meme };