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:
parent
46539d8833
commit
f4b3577801
2 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue