summary refs log tree commit diff
path: root/api/src/test
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-24 16:35:04 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-24 16:35:04 +0200
commitef4d4a318176c3e572adc17427a8b8c728a618ab (patch)
treed95fedbf18b7b7438613b08b72eb30fa5fca8921 /api/src/test
parent:sparkles: typeorm entities (diff)
downloadserver-ef4d4a318176c3e572adc17427a8b8c728a618ab.tar.xz
:construction: api
Diffstat (limited to 'api/src/test')
-rw-r--r--api/src/test/mongo_test.ts10
1 files changed, 5 insertions, 5 deletions
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());
 }