Add meme-adding logic

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-21 09:46:13 +03:00
parent 1b2ce96c5e
commit 4b601872bc
40 changed files with 1037 additions and 324 deletions

View File

@@ -1,5 +1,4 @@
import { Realm } from '@realm/react';
import { BSON } from 'realm';
import { BSON, Object, ObjectSchema } from 'realm';
import { Tag } from './tag';
enum MEME_TYPE {
@@ -20,33 +19,36 @@ const memeTypePlural = {
[MEME_TYPE.TEXT]: 'Text',
};
class Meme extends Realm.Object<Meme> {
// eslint-disable-next-line @typescript-eslint/naming-convention
class Meme extends Object<Meme> {
id!: BSON.UUID;
type!: MEME_TYPE;
uri!: Realm.List<string>;
uri!: string[];
hash!: string[];
size!: number;
title!: string;
description?: string;
isFavorite!: boolean;
tags!: Realm.List<Tag>;
tags!: Tag[] | Set<Tag>;
tagsLength!: number;
dateCreated!: Date;
dateModified!: Date;
dateUsed?: Date;
timesUsed!: number;
static schema: Realm.ObjectSchema = {
static schema: ObjectSchema = {
name: 'Meme',
primaryKey: 'id',
properties: {
id: { type: 'uuid', default: () => new BSON.UUID() },
type: { type: 'string', indexed: true },
uri: 'string[]',
hash: 'string[]',
size: 'int',
title: 'string',
description: 'string?',
isFavorite: { type: 'bool', indexed: true, default: false },
tags: { type: 'list', objectType: 'Tag', default: [] },
tags: { type: 'set', objectType: 'Tag', default: [] },
tagsLength: { type: 'int', default: 0 },
dateCreated: { type: 'date', default: () => new Date() },
dateModified: { type: 'date', default: () => new Date() },