Closed trevex closed 2 years ago
can you write the example schema - maybe I will be able to help from there.
@wojtek-krysiak
import Mongoose, { Schema } from 'mongoose';
const {
Map,
String,
Boolean,
ObjectId,
} = Schema.Types;
const schema = new Schema({
config: Map,
url: String,
component: {
type: String,
},
}),
Hello @wojtek-krysiak, is this feature implemented?
I'm trying to use it but not working for me.
Here is my code and result:
@Prop({ type: Map })
@ApiProperty({
example: { "1605689439": 30.32, "1605689445": 20.35 }
})
samples: Map<string, number>;
@Prop(raw({
firstName: { type: String },
lastName: { type: String }
}))
details: Record<string, any>;
I have the same issue, any workaround?
Currently we don't have plans to implement such type. It would be very hard considering current data model in AdminJS.
You could try to set type: 'mixed'
for your Map
property in resource options which will send the form data as an object, you'd have to parse it as Map by yourself before saving though.
Hi @trevex @krzysztofstudniarek just wanted to check since its been around 2 years since the last update on this thread, is adminjs now supports mongoose maps? below is my schema structure:
import mongoose, { Schema } from "mongoose";
const scenarioSchema = new Schema({ scenario: { type: String }, status: { type: String }, minPlayer: { type: Number }, maxPlayer: { type: Number }, imagePath: { type: String }, wideImagePath: { type: String }, articlePath: { type: String }, youtubePath: { type: String }, aparatPath: { type: String }, isCustom: { type: Boolean, default: false }, abilities: { type: Map, of: [ { ability: { type: Schema.Types.ObjectId, ref: "Ability", }, count: { type: Number, required: true, min: 1, default: 1, }, }, ], }, });
export default mongoose.model("scenario", scenarioSchema);
and everytime i try to open this in adminJs i am getting the following error:
2024-03-07T01:12:50.935Z error: Error Handler Middleware - Error: {"method":"GET","path":"/admin/api/resources/scenario/actions/list","errorMessage":"There are no resources with given id: \"Ability\"\nThis is the list of all registered resources you can use:\nuser, ability, room, scenario, malicious","stack":"Error: There are no resources with given id: \"Ability\"\nThis is the list of all registered resources you can use:\nuser, ability, room, scenario, malicious\n at AdminJS.findResource (file:///Users/moe/Desktop/gorgine-backend/node_modules/adminjs/lib/adminjs.js:183:13)\n at PropertyDecorator.reference (file:///Users/moe/Desktop/gorgine-backend/node_modules/adminjs/lib/backend/decorators/property/property-decorator.js:77:36)\n at file:///Users/moe/Desktop/gorgine-backend/node_modules/adminjs/lib/backend/utils/populator/populator.js:14:52\n at Array.filter (
Is Map implemented yet?
It's been almost 2.5 years, How do @adminJS team expect someone to use this in production.
To be honest, I love the admin JS, dashborad, but these kind of bugs just keeps arriving time to time in adminJS, Can't really use this in production setup now.
@codeit13 Its very frustrating for us too - we are already in production and cant use 2 collection at all because of this issue
Recently array support was implemented: https://github.com/SoftwareBrothers/admin-bro/issues/90
However currently Maps are not supported yet.
Apart from this feature request is there a way to work around this issue, e.g. representation as string (via its JSON form)?