Skip to content

Commit e05aefe

Browse files
committedSep 15, 2022
implement reversed relations
1 parent c3302a9 commit e05aefe

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed
 

‎package.json

-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,5 @@
3838
"express": "^4.17.3",
3939
"mongodb-memory-server": "^8.9.1",
4040
"mongoose": "^6.2.5"
41-
},
42-
"config": {
43-
"mongodbMemoryServer": {
44-
"debug": "1"
45-
}
4641
}
4742
}

‎src/models.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const Repository = createGraphqlModelServer({
127127
// (without having to extend the contributor model explicitely)
128128
reversedRelation: {
129129
model: Contributor,
130-
kind: "belongsToOne",
130+
kind: "hasOneReversed",
131131
foreignFieldName: "repository",
132132
},
133133
canRead: ["guests", "anyone"],

‎src/seedDemoDb.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export const seedDemoDb = async () => {
1616
const contributor = await contributorMongooseModel.create({
1717
name: "John Doe",
1818
});
19-
console.log("Done seeding db with 1 contributor");
19+
console.log("Done seeding db with 1 contributor", contributor._id);
2020
const repoMongooseModel = mongoose.models[Repository.name];
2121
await repoMongooseModel.deleteMany({});
22-
await repoMongooseModel.create({
22+
const repository = await repoMongooseModel.create({
2323
url: "https://github.com/VulcanJS/vulcan-npm",
2424
contributorId: contributor._id,
2525
});
26-
console.log("Done seeding db with 1 repository");
26+
console.log("Done seeding db with 1 repository", repository);
2727
};
2828

2929
/**

0 commit comments

Comments
 (0)
Please sign in to comment.