adminjs
adminjs copied to clipboard
[Bug]: Unable to filter in list view of collection with a property consisting of an array of string enums as property.
Contact Details
No response
What happened?
So I have a collection with a property containing an array of string items as enums, how can I filter based on these values in the collection page i.e. http://localhost:8080/admin/resources/SomeCollection
.
Here's the code for the collection's schema:
someCollection.model.ts :
export const SomeCollectionSchema = new mongoose.Schema({
selectedTags: {
type: [String],
enum: ["sampleTag_1","sampleTag_2","sampleTag_3"]
},
createdAt: {
type: Date,
default: Date.now,
},
updatedAt: {
type: Date,
default: Date.now,
},
});
export const SomeCollection = mongoose.model("SomeCollection", SomeCollectionSchema);
And here's the resource file for this collection:
someCollection.options.ts :
export const SomeCollectionResourceOptions = {
options: {
listProperties: ["_id", "selectedTags", "createdAt", "updatedAt"],
sort: {
sortBy: "createdAt",
direction: "desc",
},
properties: {
selectedTags: {
type: "string",
isArray: true,
availableValues: ["sampleTag_1", "sampleTag_2", "sampleTag_3"].map(
(tag) => ({
value: tag,
label: tag,
})
),
},
},
},
}
The tags are working fine when creating a new or viewing or editing an existing file. But I cannot filter based on them, what do I need to do to enable filtering based on these enum tags?
Bug prevalence
All the time
AdminJS dependencies version
"adminjs": "^6.6.5",
"@adminjs/design-system": "^3.0.4",
"@adminjs/express": "^5.0.1",
"@adminjs/logger": "^4.0.1",
"@adminjs/mongoose": "^3.0.1",
What browsers do you see the problem on?
No response
Relevant log output
No response