Hey guys!
As posted in some other(s) topic(s), I have a couple of collection(s) (mongodb) but for some of them, I have documents like this:
Note: I will only show an “interface” approche, but schema would result to be the same, don’t worry, we keep it simple.
item.ts
import { Schema, Document, model} from 'mongoose';
import * as notes, {INotes} from './notes.ts';
interface IItem extends Document {
notes: [INote],
// ...
}
const schema = new Schema({
'notes': [notes]
// ...
}, {
timestamps: false,
});
export default model<IItem>('items', schema, 'Items');
So, note is basically a simple model which isn’t a collection itself and used only as nested document schema.
note.ts
import { Schema, Document, model, Types} from 'mongoose';
export interface INote extends Document {
title: string,
message: string,
author_id: Types.ObjectId
}
const schema = new Schema({
"title": String,
"message": String,
'author_id': { type: Types.ObjectId, ref: 'xxx' },
}, {
timestamps: false,
});
export default model<INote>('notes', schema);
The thing is, I am able to edit the layout from Forest Admin UI of the items (the collection display, the single item fields, etc) but I am not able to edit the fields types.
By example, one of the field is an author ID and, instead of a “text input”, I would like to put a Dropdown because I am in the same situation as I was in this topic: Dropdown(s) of constants/foreign keys on create/update from UI - #3 by Emixam23 @Arnaud_Moncel @remi.
I searched but couldn’t find the way to edit the “widget” from “text input” to “dropdown” when it’s a nested document.
I am close to be done, it’s amazing how fast you can build a backoffice using forest admin when you don’t have much skills in web dev!
Thanks!
Max,