summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-07 04:01:47 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-07 04:01:47 +0200
commit084c396e8d85da5450f50bb3a3631a8621d9eb21 (patch)
treee26ff79649e12936777d89656a0e5f831aebcd2c /src
parent:bug: fix lean not working with virtuals (diff)
downloadserver-084c396e8d85da5450f50bb3a3631a8621d9eb21.tar.xz
fix toObject type
Diffstat (limited to 'src')
-rw-r--r--src/util/Database.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/util/Database.ts b/src/util/Database.ts
index e17eeccb..5d9afab9 100644
--- a/src/util/Database.ts
+++ b/src/util/Database.ts
@@ -1,5 +1,5 @@
 import "./MongoBigInt";
-import mongoose, { Collection, Connection } from "mongoose";
+import mongoose, { Collection, Connection, LeanDocument } from "mongoose";
 import { ChangeStream, ChangeEvent, Long } from "mongodb";
 import EventEmitter from "events";
 import { Document } from "mongoose";
@@ -11,11 +11,13 @@ const connection = mongoose.createConnection(uri, { autoIndex: true, useNewUrlPa
 
 export default <Connection>connection;
 
-function transform<T extends Document>(document: T) {
+function transform<T>(document: T) {
+	// @ts-ignore
 	return document.toObject({ virtuals: true });
 }
 
-export function toObject<T extends Document>(document: T | T[]) {
+export function toObject<T>(document: T): LeanDocument<T> {
+	// @ts-ignore
 	return Array.isArray(document) ? document.map((x) => transform<T>(x)) : transform(document);
 }