GithubHelp home page GithubHelp logo

Comments (12)

anilprasad avatar anilprasad commented on June 21, 2024 1

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.

arnaudbesnier avatar arnaudbesnier commented on June 21, 2024

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.

ItsMrAkhil avatar ItsMrAkhil commented on June 21, 2024

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.
screen_forest_admin_error

In the image, paymentBy has to be populated based on paymentByUserType.

Best regards,
Akhil

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on June 21, 2024

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.

BenjaminG avatar BenjaminG commented on June 21, 2024

Hi @arnaudbesnier Any updates on this ? Is it still planned in your backlog ?

from forest-express-mongoose.

akashdeepsinghal avatar akashdeepsinghal commented on June 21, 2024

waiting for this

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on June 21, 2024

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.

louisteenbrink avatar louisteenbrink commented on June 21, 2024

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.

ItsMrAkhil avatar ItsMrAkhil commented on June 21, 2024

@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.

arnaudbesnier avatar arnaudbesnier commented on June 21, 2024

@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.

ItsMrAkhil avatar ItsMrAkhil commented on June 21, 2024

@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.

arnaudbesnier avatar arnaudbesnier commented on June 21, 2024

Yes you can fork the repo and suggest changes that would support this feature.

from forest-express-mongoose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.