Files
myDrive/backend/db/mongoDB/thumbnailDB.ts
T
oxmc ecc340e7b1
Release Please / release-please (push) Has been cancelled
Docker Build and Push (Development) / build-and-push-dev (push) Has been cancelled
feat: add dark mode UI and SQLite as alternate database backend
Dark mode: CSS custom properties + .dark class toggled via Redux/localStorage,
with a theme toggle in the Header and Settings page. Foundation didn't exist
yet despite prior assumption, so it was built from scratch.

SQLite: new DB_ENGINE=mongo|sqlite env var selects the metadata backend at
runtime (Mongo stays default, no behavior change unless opted in). File/thumbnail
bytes continue to use the existing fs/S3 storage path. Implemented via a shared
DB interface (dbTypes.ts) with parallel mongoDB/ and sqliteDB/ implementations,
selected through dbFactory.ts, with JWT/encryption logic extracted into
userCrypto.ts so both engines share it.
2026-07-05 04:18:33 -07:00

44 lines
916 B
TypeScript

import Thumbnail from "../../models/thumbnail-model";
import { ObjectId } from "mongodb";
import { IThumbnailDB } from "../dbTypes";
class ThumbnailDB implements IThumbnailDB {
constructor() {}
// READ
getThumbnailInfo = async (userID: string, thumbnailID: string) => {
const thumbnail = await Thumbnail.findOne({
_id: new ObjectId(thumbnailID),
owner: userID,
});
return thumbnail;
};
// DELETE
removeThumbnail = async (userID: string, thumbnailID: ObjectId) => {
const result = await Thumbnail.deleteOne({
_id: thumbnailID,
owner: userID,
});
return result;
};
// CREATE
createThumbnail = async (data: {
name: string;
owner: string;
IV: Buffer;
path?: string;
s3ID?: string;
}) => {
const thumbnail = new Thumbnail(data as any);
await thumbnail.save();
return thumbnail;
};
}
export default ThumbnailDB;