1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-19 21:29:41 +02:00

🤩MongoDB support 🤩 (#272)

* implement configuration through YAML

* remove rcparser

* use password from appConfig

* update docker configs

* fix dockerignore

* implement mongodb driver

* update eslint packages

* fix bugs

* refactor code for grouping by parent

* fix yet another bug

* use unique symbol to the EntityId type

* fix more bugs

* implement db converter

* fix bug with parent selector

* fix eslint

* db-converter refactoring

* create cli program for db-converter

* add readme and gitignore

* update development docs

* update development docs and default config

* add docs about converter

* add src/test to docker ignore

* move database code from utils

* improve docs

* eslint fix

* add more docs

* fix docs

* remove env_file from docker-compose

* implement duplicate detection in db-converter

* use published version of the config-loader

* fix bug

* Update DEVELOPMENT.md

Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com>

* fix bugs

* fix next/prev buttons

* fix more bugs

* fix sorting

Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com>
This commit is contained in:
Nikita Melnikov 2022-10-03 16:23:59 +04:00 committed by GitHub
parent 13762096c4
commit 55b4b3ee61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 12614 additions and 665 deletions

View file

@ -0,0 +1,50 @@
import { AliasData } from '../models/alias.js';
import { FileData } from '../models/file.js';
import { PageData } from '../models/page.js';
import { PageOrderData } from '../models/pageOrder.js';
import appConfig from '../utils/appConfig.js';
import LocalDatabaseDriver from './local.js';
import MongoDatabaseDriver from './mongodb.js';
import { EntityId } from './types.js';
import { ObjectId } from 'mongodb';
const Database = appConfig.database.driver === 'mongodb' ? MongoDatabaseDriver : LocalDatabaseDriver;
/**
* Convert a string to an EntityId (string or ObjectId depending on the database driver)
*
* @param id - id to convert
*/
export function toEntityId(id: string): EntityId {
if (id === '0') {
return id as EntityId;
}
return (appConfig.database.driver === 'mongodb' ? new ObjectId(id) : id) as EntityId;
}
/**
* Check if provided ids are equal
*
* @param id1 - first id
* @param id2 - second id
*/
export function isEqualIds(id1?: EntityId, id2?: EntityId): boolean {
return id1?.toString() === id2?.toString();
}
/**
* Check if provided ids are valid
*
* @param id - id to check
*/
export function isEntityId(id?: EntityId): id is EntityId {
return typeof id === 'string' || id instanceof ObjectId;
}
export default {
pages: new Database<PageData>('pages'),
aliases: new Database<AliasData>('aliases'),
pagesOrder: new Database<PageOrderData>('pagesOrder'),
files: new Database<FileData>('files'),
};