Browse Source

fix: turn ObjectID into string before going to DB, fixes creating news and such

Kristian Vos 2 months ago
parent
commit
2303772933
1 changed files with 3 additions and 2 deletions
  1. 3 2
      backend/src/modules/DataModule.ts

+ 3 - 2
backend/src/modules/DataModule.ts

@@ -14,6 +14,7 @@ import {
 import { Dirent } from "fs";
 import * as inflection from "inflection";
 import { SequelizeStorage, Umzug } from "umzug";
+import ObjectID from "bson-objectid";
 import BaseModule, { ModuleStatus } from "@/BaseModule";
 import DataModuleJob from "./DataModule/DataModuleJob";
 import Job from "@/Job";
@@ -55,8 +56,8 @@ export class OBJECTID extends DataTypes.ABSTRACT.prototype.constructor {
 	// Optional: value stringifier before sending to database
 	// @ts-ignore
 	_stringify(value) {
-		return value;
-		// return value.toString();
+		if (value instanceof ObjectID) return value.toHexString();
+		return value.toString();
 	}
 
 	// Optional: parser for values received from the database