With two feathers services at hand, one for handling profiles and another for labels, the possibilities are endless.
In a profile, you can have an array of ObjectId labels from other collections. Imagine the depth of connections!
Now, picture this scenario: a user enters "linux" in the search input field.
The profile named foo should be retrieved because it contains the ID "594ceeff6905e622425f523b" in its labels array.
Is this kind of search query, involving ObjectIDs between objects, feasible using Feathers?
Profiles
Mongoose model
{
name: { type: String, trim: true, required: true },
labels: [{ type: ObjectId, ref: 'Labels' }],
}
Feathers API response for profiles
Accessible via: http://localhost:3030/profiles
{
"name": "foo",
"labels": [
"594ceeff6905e622425f523b",
"594ceeff6905e622425f523c",
"594ceeff6905e622425f523d"
],
}
{
"name": "bar",
"labels": [
"594ceeff6905e622425f523e",
"594ceeff6905e622425f523d"
],
}
Labels
Mongoose model
{
name: { type: String, trim: true, unique: true, required: true },
}
Feathers API response for labels
Accessed through: http://localhost:3030/labels
{
"_id": "594ceeff6905e622425f523b",
"name": "linux"
},
{
"_id": "594ceeff6905e622425f523c",
"name": "systemd"
},
{
"_id": "594ceeff6905e622425f523d",
"name": "mongodb"
},
{
"_id": "594ceeff6905e622425f523e",
"name": "javascript"
}
But as the list of labels grows, populating all labels into the profiles response, sending them all to filter on the frontend based on the search value might not be the most efficient approach.
There must be a better way to handle this as the database expands. Any ideas?