1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-08 06:55:26 +02:00

fix sorting

This commit is contained in:
Nikita Melnikov 2022-10-03 20:16:35 +08:00
parent 46539d8833
commit f4b3577801
2 changed files with 6 additions and 1 deletions

View file

@ -16,6 +16,10 @@ const Database = appConfig.database.driver === 'mongodb' ? MongoDatabaseDriver :
* @param id - id to convert * @param id - id to convert
*/ */
export function toEntityId(id: string): EntityId { export function toEntityId(id: string): EntityId {
if (id === '0') {
return id as EntityId;
}
return (appConfig.database.driver === 'mongodb' ? new ObjectId(id) : id) as EntityId; return (appConfig.database.driver === 'mongodb' ? new ObjectId(id) : id) as EntityId;
} }

View file

@ -58,7 +58,8 @@ router.get('/pages', async (req: Request, res: Response) => {
*/ */
router.put('/page', multer.none(), async (req: Request, res: Response) => { router.put('/page', multer.none(), async (req: Request, res: Response) => {
try { try {
const { title, body, parent } = req.body; const { title, body } = req.body;
const parent = toEntityId(req.body.parent);
const page = await Pages.insert({ const page = await Pages.insert({
title, title,
body, body,