Hello everyone.
I forked the ghost repo to implement some features specific to the context I work in. One of these features is a new hasMany relation in the post model with a new table called external_associations, I’m pretty much done with it except for api filtering.
Like we can do with tags:
localhost:2368/ghost/api/v2/admin/posts/?filter=tags.id:5dba1d1ad300076498ebbf55
I’d like to do with my new relation:
localhost:2368/ghost/api/v2/admin/posts/?filter=external_associations.module_id:5dba1c35d300076498ebbf50
While messing with the code I found this file /core/server/models/plugins/filter.js wich has the following const:
const RELATIONS = {
tags: {
tableName: 'tags',
type: 'manyToMany',
joinTable: 'posts_tags',
joinFrom: 'post_id',
joinTo: 'tag_id'
},
authors: {
tableName: 'users',
tableNameAs: 'authors',
type: 'manyToMany',
joinTable: 'posts_authors',
joinFrom: 'post_id',
joinTo: 'author_id'
}
};
I’d like to replicate these entries for a oneToMany relation with the table I created, I tried the following:
external_associations: {
tableName: 'external_associations',
type: 'oneToMany',
joinFrom: 'post_id'
}
But I had no success.
I don’t know if this is the right place for these kind of questions, if not I apologize, if yes thank you for reading until the end.
The ghost version I’m using is 2.11.1