Object's values in array of objects aren't displayed
Describe the bug When I try to view a document with array of objects, the values aren't displayed, but everything in Mongo seems fine.
Installed libraries and their versions
- [email protected]
- @adminjs/[email protected]
- @adminjs/[email protected]
- "express": "4.18.1",
- "mongodb": "4.8.0",
- "mongoose": "6.5.2",
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior Display all values.
Screenshots

AdminJSOptions with schema Options
import AdminJS from "adminjs";
import AdminJSMongoose from "@adminjs/mongoose";
import { Order } from "../models/order.js";
AdminJS.registerAdapter(AdminJSMongoose);
export const adminOptions = new AdminJS({
resources: [{ resource: Order }],
rootPath: "/admin",
});
Mongo Schema
import mongoose from "mongoose";
const Schema = mongoose.Schema;
const orderSchema = new Schema(
{
test: { type: String },
array: [
{
_id: false,
material: {
name: {
type: String,
},
colors: [
{
_id: false,
name: { type: String },
},
],
},
},
],
},
{ versionKey: false }
);
export const Order = mongoose.model("Order", orderSchema);
Desktop (please complete the following information if relevant):
- OS: Windows 10
- Browser Chrome
- Version [e.g. 22]
Additional context Neither of name in material or name in the array of object is displayed.
You either have to define every sub property with new Schema(...):
material: new Schema(...)
or describe properties in AdminJS resource options for your model - this is how it works for every other adapter/orm/odm:
properties: {
array: {
isArray: true,
type: 'mixed',
},
'array.material': {
type: 'mixed'
},
'array.material.name': {
type: 'string'
},
'array.material.colors': {
type: 'mixed',
isArray: true,
},
'array.material.colors.name': {
type: 'string',
},
}
Using the first solution works. But with the second I'm getting the fields but with no values.

Can you show how record.params look like in your Network response?
"params":{
"_id":"633bf47f72bb0e3f0e371d12",
"array.0.material.name":"testName",
"array.0.material.colors.0.name":"colorName",
"test":"test"
},
This seems to be a correct response to me. Did you consider updating adminjs to the latest version? I think there were some fixes to mixed type throughout the last year or two.
There has been a mistake in the description. My version is 6.2.4.
I am using version 6.6.5 with the exactly same issue.
@sourabh1983 do you also use mongoose?
@sourabh1983 do you also use mongoose?
I am using Prisma
below is response.record.params
{
Id: '03b94717-5650-43bc-9e70-cde47d942f98',
Name: "ICC U19 Men's Cricket World Cup",
ShortName: 'ICC U19 M CWC',
participatingTeams: [
{
Id: '0124b967-3a01-4ccb-8032-857e5d077604',
CompetitionId: '03b94717-5650-43bc-9e70-cde47d942f98',
TeamId: '7a5c8ec9-981c-4de7-bf53-2d39b48c2661',
Name: 'Pakistan Under-19s'
},
{
Id: '15d316cc-abbd-4b0b-9737-9a36f372ffdb',
CompetitionId: '03b94717-5650-43bc-9e70-cde47d942f98',
TeamId: '6557735a-b611-4dfd-9e66-52e9e184375b',
Name: 'Papua New Guinea Under-19s'
},
...
]
}
{
resource: {model: dmmf.modelMap.Competitions, client: prismaClient},
options: {
navigation: {
icon: 'Trophy'
},
properties: {
participatingTeams: {
isVisible: {
edit: false,
list: false,
filter: false,
show: true,
},
type: 'mixed',
isArray: true,
},
'participatingTeams.Name': {
type: 'string',
},
}
}
}

How do you get participatingTeams? AdminJS uses a flat data model so if participatingTeams is structured as a nested json it won't work.
Your response should look like:
// other params
participatingTeams.0.Id: '0124b967-3a01-4ccb-8032-857e5d077604',
participatingTeams.0.CompetitionId: '03b94717-5650-43bc-9e70-cde47d942f98',
participatingTeams.0.TeamId: '7a5c8ec9-981c-4de7-bf53-2d39b48c2661',
participatingTeams.0.Name: 'Pakistan Under-19s',
participatingTeams.1.Id: '15d316cc-abbd-4b0b-9737-9a36f372ffdb',
participatingTeams.1.CompetitionId: '03b94717-5650-43bc-9e70-cde47d942f98',
participatingTeams.1.TeamId: '6557735a-b611-4dfd-9e66-52e9e184375b',
participatingTeams.1.Name: 'Papua New Guinea Under-19s'