diff --git a/.vscode/launch.json b/.vscode/launch.json
index 570e485a..557fb6d7 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -19,6 +19,7 @@
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
+ "preLaunchTask": "tsc: build - tsconfig.json",
"type": "node",
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"]
}
diff --git a/package-lock.json b/package-lock.json
index dff1862c..72f21935 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1363,7 +1363,7 @@
},
"node_modules/fosscord-server-util": {
"version": "1.0.0",
- "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#371a56859695321bfa862a1c66d27279018cc864",
+ "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#3bdbd9340edf4f3edd728624499dbcaaf08a25ed",
"license": "ISC",
"dependencies": {
"jsonwebtoken": "^8.5.1",
@@ -5077,7 +5077,7 @@
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
},
"fosscord-server-util": {
- "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#371a56859695321bfa862a1c66d27279018cc864",
+ "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#3bdbd9340edf4f3edd728624499dbcaaf08a25ed",
"from": "fosscord-server-util@github:fosscord/fosscord-server-util",
"requires": {
"jsonwebtoken": "^8.5.1",
diff --git a/src/routes/api/v8/channels/#CHANNELID/invites.ts b/src/routes/api/v8/channels/#CHANNELID/invites.ts
index ee71d1ee..9d03d9f0 100644
--- a/src/routes/api/v8/channels/#CHANNELID/invites.ts
+++ b/src/routes/api/v8/channels/#CHANNELID/invites.ts
@@ -39,7 +39,7 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response)
inviter_id: usID,
};
- await new InviteModel(invite).save(); // ! samuel ist ein hurensohn
+ await new InviteModel(invite).save();
await emitEvent({ event: "INVITE_CREATE", data: invite } as InviteCreateEvent);
res.status(201).send(invite);
diff --git a/src/test/mongo_test.ts b/src/test/mongo_test.ts
index 5c973429..f1a7f3f6 100644
--- a/src/test/mongo_test.ts
+++ b/src/test/mongo_test.ts
@@ -2,13 +2,26 @@ import mongoose, { Schema, Types } from "mongoose";
import { Long as MongoTypeLong } from "mongodb";
require("mongoose-long")(mongoose);
-const partSchema = new Schema({
- long: {
- type: mongoose.Types.Long,
- },
+const userSchema = new Schema({
+ id: MongoTypeLong,
});
-const Part = mongoose.model("Part", partSchema, "test");
+const messageSchema = new Schema({
+ id: MongoTypeLong,
+ content: String,
+});
+const message = mongoose.model("message", messageSchema, "messages");
+const user = mongoose.model("user", userSchema, "users");
+
+messageSchema.virtual("u", {
+ ref: user,
+ localField: "id",
+ foreignField: "id",
+ justOne: true,
+});
+
+messageSchema.set("toObject", { virtuals: true });
+messageSchema.set("toJSON", { virtuals: true });
async function main() {
const conn = await mongoose.connect("mongodb://localhost:27017/lambert?readPreference=secondaryPreferred", {
@@ -17,12 +30,12 @@ async function main() {
});
console.log("connected");
- const part = new Part({ long: 390810485244821505n });
+ // const u = await new user({ name: "test" }).save();
+ // await new message({ user: u._id, content: "test" }).save();
- // await part.save();
- console.log("saved");
- const test = await Part.find({});
- console.log(test);
+ const test = await message.findOne({}).populate("u").exec();
+ // @ts-ignore
+ console.log(test?.toJSON());
}
main();
|