Comments (12)
I have got a workaround without referring the object:
Following is an example:
const mongoose = require('mongoose');
const schema = mongoose.Schema({
user: {
type: mongoose.Schema.Types.ObjectId, // refer as the mongoose ObjectID type
// ref: 'users', // avoid referring the object to any other collection
required: true
},
planName: {
type: String
....................
from forest-express-mongoose.
Hi @ItsMrAkhil, thank you for the idea!
Can you provide a small piece of code to help us reproduce and implement the refPath
support?
🌲🌲🌲
from forest-express-mongoose.
Hi, @arnaudbesnier Let me explain it in a clear way.
Let's say I have three mongoose schemas like below
AdminSchema:
{
name: { type: String },
email: { type: String },
}
UserSchema:
{
name: { type: String },
email: { type: String },
}
BookingSchema:
{
item: { type: mongoose.Schema.Types.ObjectId, ref: 'item' }, // Currently supported by forest admin
createdBy: { type: mongoose.Schema.Types.ObjectId, refPath: 'createdByUserType' }, // Currently not supported by forest admin
createdByUserType: { type: String, enum: ['Admin', 'User'] },
}
If we want to create a booking and we have only one user schema we all set to go with current forest admin. But if we do not know who is going to create a booking and you want mongoose population to work properly you need to use refPath provided by the mongoose.
And now the problem with the current forest admin is -> it is not showing the related details of createdBy
field in the document. In this place, it is showing the object id which is not so great. Whereas I am expecting the populated document details (So, that I can choose whatever field I want. In my case it is name
in both schemas AdminSchema
as well as in UserSchema
). I am attaching an image below as an example.
In the image, paymentBy
has to be populated based on paymentByUserType
.
Best regards,
Akhil
from forest-express-mongoose.
Thanks @ItsMrAkhil, it is crystal clear.
This is a feature we really need to have. I'll add a story for this in our backlog but I cannot provide any ETA at this time.
from forest-express-mongoose.
Hi @arnaudbesnier Any updates on this ? Is it still planned in your backlog ?
from forest-express-mongoose.
waiting for this
from forest-express-mongoose.
Hey @BenjaminG @akashdeepsinghal This feature is not yet planned in our 6-weeks roadmap.
This is something more and more customers are asking for (accross the stacks). I cannot provide any ETA but it could be prioritised in a few months.
from forest-express-mongoose.
Hi @akashdeepsinghal, can you precise me your Forest Admin project name to note your request in our roadmap? You can contact me at [email protected]. Thanks
from forest-express-mongoose.
@arnaudbesnier It's been a couple of years since I open this issue. Still looking forward to the solution. Any ETA on this?
from forest-express-mongoose.
@ItsMrAkhil, I am sorry to tell you that there is no ETA for this feature request.
We'd love to have the time to implement this feature, but we're still a small team focused on other top priorities.
Thanks for your patience.
from forest-express-mongoose.
@arnaudbesnier Can I create my own PR for this? Because it will help me a lot if I have this feature.
from forest-express-mongoose.
Yes you can fork the repo and suggest changes that would support this feature.
from forest-express-mongoose.
Related Issues (20)
- TypeError: Class constructor ObjectId cannot be invoked without 'new' HOT 4
- export ResourceSerializer in type definition
- Forest Admin UI incorrectly display nested field HOT 2
- Smart Ations fields hooks endpoint cannot authenticate HOT 5
- Is this still supported? HOT 2
- Update document example from documentation doesn't seem to work HOT 1
- TypeError: RecordsRemover is not a constructor HOT 3
- Forest Admin Dashboard display mongoose mixed data type as [object,object]
- Forestadmin with Typescript project and MongoDB Atlas Free Plan
- Should be able to specify location of .forestadmin-schema.json HOT 1
- Non-Date types that store Date values cannot be rendered as a time-based Chart HOT 1
- Nested Enum types do not have values in the schema and crash the Create page in the UI HOT 7
- Smart relationship does not query the route HOT 4
- Smart actions - primaryKeys not generated in forestadmin schema HOT 2
- Smart Relationships are all empty in 7.8.4 and after
- Weird behaviour with certain model names HOT 1
- Having trouble connecting HOT 2
- Impossible to delete values in array field
- Can't user react components for smart views
- Vulnerability Notice on moment-timezone. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forest-express-mongoose.