From ef4d4a318176c3e572adc17427a8b8c728a618ab Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Tue, 24 Aug 2021 16:35:04 +0200 Subject: :construction: api --- api/src/test/mongo_test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'api/src/test') diff --git a/api/src/test/mongo_test.ts b/api/src/test/mongo_test.ts index 44b04c5b..bf203ea6 100644 --- a/api/src/test/mongo_test.ts +++ b/api/src/test/mongo_test.ts @@ -2,12 +2,12 @@ import mongoose, { Schema, Types } from "mongoose"; require("mongoose-long")(mongoose); const userSchema = new Schema({ - id: String, + id: String }); const messageSchema = new Schema({ id: String, - content: String, + content: String }); const message = mongoose.model("message", messageSchema, "messages"); const user = mongoose.model("user", userSchema, "users"); @@ -16,7 +16,7 @@ messageSchema.virtual("u", { ref: user, localField: "id", foreignField: "id", - justOne: true, + justOne: true }); messageSchema.set("toObject", { virtuals: true }); @@ -25,14 +25,14 @@ messageSchema.set("toJSON", { virtuals: true }); async function main() { const conn = await mongoose.connect("mongodb://localhost:27017/lambert?readPreference=secondaryPreferred", { useNewUrlParser: true, - useUnifiedTopology: false, + useUnifiedTopology: false }); console.log("connected"); // const u = await new user({ name: "test" }).save(); // await new message({ user: u._id, content: "test" }).save(); - const test = await message.findOne({}).populate("u").exec(); + const test = await message.findOneOrFail({}).populate("u"); // @ts-ignore console.log(test?.toJSON()); } -- cgit 1.4.1