GithubHelp home page GithubHelp logo

Comments (7)

ozomer avatar ozomer commented on July 20, 2024 1

We have the same problem over here.
Actually this can be solved with a smart collection of sub-documents, with a one-to-many relationship between the parent document and the sub-documents, by implementing the json-api.
The "id" of each subdocument should contain both the the id of the parent document and the id of the sub-document to avoid collisions between two sub-documents with the same id that reside in two different parent documents. This can be skipped if the sub-documents' ids are unique (i.e. when they are autogenerated by mongoose). Also, each subdocument should have a reference to its exactly-one parent document, and an index for its position inside the parent document array.
The references themselves the be implemented with Liana smart relationships.
Paging can also be a non-trivial because of the ordering. It could be solved by sorting the subdocuments first by the parent-id and then by their own subdocument-id.

Flattening all the models could annoying, especially if you are actually modeling a tree structure, i.e. "Project" containing an array of "Sections", containing an array of "Tasks". This is one of the greatest advantages of NoSql - you can simply load the document with Robo3t or other clients, load the document, and see the tree-structure without needing to write code for populating all the arrays of references.

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on July 20, 2024

Hi @Listu, we'll look at your issue next week!

from forest-express-mongoose.

root-io avatar root-io commented on July 20, 2024

Hey @Listu we were wondering if you could give us a sample of data you had in your database. A Society document with the embedded members. Thanks !

from forest-express-mongoose.

Listu avatar Listu commented on July 20, 2024

Of course @root-io
Hope it helps !

`
{

    "_id" : ObjectId("5b8fde138e931929505a087a"),
    "updatedAt" : ISODate("2018-09-17T09:11:03.086Z"),
    "createdAt" : ISODate("2018-09-05T13:45:56.398Z"),
    "name" : "SPT",
    "address" : {
            "place_id" : "ChIJfXRynsNv5kcRZ9ypL-zaaoI",
            "country" : "France",
            "city" : "Paris",
            "area" : "Paris",
            "street" : "37 Rue Marbeuf",
            "postal_code" : "75008",
            "coordinates" : [
                    48.86967500000001,
                    2.305317000000059
            ],
            "_id" : ObjectId("5b8fde138e931929505a0882")
    },
    "invitations" : [ ],
    "status" : 0,
    "stripe" : "**************",
    "billingFrequency" : 2,
    "billings" : [
            {
                    "_id" : ObjectId("5b8fde138e931929505a0878"),
                    "address" : {
                            "place_id" : "ChIJfXRynsNv5kcRZ9ypL-zaaoI",
                            "country" : "France",
                            "city" : "Paris",
                            "area" : "Paris",
                            "street" : "37 Rue Marbeuf",
                            "postal_code" : "75008",
                            "coordinates" : [
                                    48.86967500000001,
                                    2.305317000000059
                            ],
                            "_id" : ObjectId("5b8fde138e931929505a0879")
                    },
                    "nic" : "63214",
                    "siren" : "123654789",
                    "capital" : 15000,
                    "raison" : "SPT",
                    "service" : null
            },
            {
                    "_id" : ObjectId("5b9f6ee870be0f42d0a0384e"),
                    "address" : {
                            "place_id" : "ChIJfXRynsNv5kcRZ9ypL-zaaoI",
                            "city" : "Paris",
                            "area" : "Paris",
                            "country" : "France",
                            "postal_code" : "75008",
                            "street" : "37 Rue Marbeuf",
                            "coordinates" : [
                                    48.86967500000001,
                                    2.305317000000059
                            ],
                            "_id" : ObjectId("5b9f6ee870be0f42d0a0384f")
                    },
                    "capital" : 10000,
                    "nic" : "12355",
                    "siren" : "123456789",
                    "raison" : "TEST",
                    "service" : "Yolo"
            }
    ],
    "members" : [
            {
                    "updatedAt" : ISODate("2018-09-05T13:45:56.396Z"),
                    "createdAt" : ISODate("2018-09-05T13:45:56.396Z"),
                    "user" : ObjectId("5b8fde128e931929505a085d"),
                    "billing" : ObjectId("5b8fde138e931929505a0878"),
                    "politic" : {
                            "_id" : ObjectId("5b8fdd468e931929505a0776"),
                            "rental" : {
                                    "maxprice" : 100
                            },
                            "price" : {
                                    "min" : 0,
                                    "max" : 500,
                                    "_id" : ObjectId("5b8fdd468e931929505a0777")
                            },
                            "stars" : {
                                    "min" : 1,
                                    "max" : 5,
                                    "_id" : ObjectId("5b8fdd468e931929505a0778")
                            }
                    },
                    "_id" : ObjectId("5b8fde138e931929505a087b"),
                    "roles" : [
                            "executive"
                    ]
            },
            {
                    "updatedAt" : ISODate("2018-09-17T09:11:03.085Z"),
                    "createdAt" : ISODate("2018-09-17T09:10:52.029Z"),
                    "user" : ObjectId("5b9f6f9b70be0f42d0a03881"),
                    "politic" : {
                            "flight" : {
                                    "price" : {
                                            "max" : 1100,
                                            "min" : 0
                                    },
                                    "class" : "business"
                            },
                            "_id" : ObjectId("5b9f6fa770be0f42d0a03aac"),
                            "rental" : {
                                    "maxprice" : 100
                            },
                            "price" : {
                                    "min" : 0,
                                    "max" : 500,
                                    "_id" : ObjectId("5b9f6fa770be0f42d0a03aad")
                            },
                            "stars" : {
                                    "min" : 2,
                                    "max" : 5,
                                    "_id" : ObjectId("5b9f6fa770be0f42d0a03aae")
                            }
                    },
                    "billing" : ObjectId("5b9f6ee870be0f42d0a0384e"),
                    "_id" : ObjectId("5b9f6f9c70be0f42d0a03888"),
                    "roles" : [
                            "traveler"
                    ]
            }
    ],
    "__v" : 1

}
`

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on July 20, 2024

Hi @Listu, this is currently a limitation of our platform.

In the case of arrays of embedded document that contain only keys/values with a "single depth level", these arrays will appear in the "Related Data" section.

For more complex documents in embedded arrays, as the edition may be very complex, we display a JSON field to manipulate the data. This is clearly not an ideal usage, but at least you can read and manipulate the data. We definitely need to work on this.

from forest-express-mongoose.

Listu avatar Listu commented on July 20, 2024

Ok so we have to change our model, wait an improvement or dev our own dashboard. Thank you for the help.

from forest-express-mongoose.

roonie007 avatar roonie007 commented on July 20, 2024

Any news on this ?

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.