graffiti-mongoose
graffiti-mongoose copied to clipboard
Query by reference
Hi, newbie question here, how can I query by model reference?
I would like to query all Topic-models of certain Forum, my models (simplified):
var Topic = new Schema({
uuid: {
type: String,
index: true,
unique: true
},
title: {
type: String
},
forum: {
type: ObjectId,
ref: "Forum",
index: true
},
})
var Forum = new Schema({
title: {
type: String,
required: true
}
});
I would like to
query TopicsByForum{
topics(forum:"nnn"){
forum{title}
}
}
I made a PR for this issue https://github.com/RisingStack/graffiti-mongoose/pull/112
Dont think this is relay supported. Why would you have topics as a parent of forum anyways?
Makes more sense if it is like this:
query ForumTopics{
forum(title:"nnn"){
topics{
uuid
title
}
}
}