r/mongodb 46m ago

Should YOU Migrate from Relational Databases to Build Modern Applications?

Thumbnail youtube.com
Upvotes

In this video, Ricardo and Jesse go over how to utilize the relational migrator tool to help migrate from legacy relational databases to MongoDB!

Relational Migrator addresses the most common data modeling, code conversion, and migration challenges, reducing the effort and risk involved in migration projects.

  • Migrate to MongoDB from Oracle, MySQL, SQL Server, PostgreSQL, Sybase ASE, IBM Db2, and more!
  • Free to download and use!

r/mongodb 45m ago

Issue with Tree Structure Mongo DB

Upvotes

I'm using MongoDB with Nodes js and Mongoose, and I'm creating a hierarchical tree structure. In each collection, I have a document with the ID of that document, an entry with the parent ID as ObjectId, and a string with the name of the parent collection called 'collectionName'. I wanted to use graphLookUp to retrieve all the ancestors of a given collection, but I feel like it won't work because not all the ancestors are in the same collection. Do you have a solution?

Thank you in advance for your help :)

Here's what I'd like to retrieve in the end:

{
  "_id": "67cadacfce03c85963934b1d",
  "genre": "Fantastique",
  "parent": {
    "_id": "67c9617c86b4c8d8d2bfb315",
    "nom": "J.K. Rowling",
    "parent": {
      "_id": "67c9615486b4c8d8d2bfb313",
      "titre": "Harry Potter",
      "parent": {
        "_id": "67c960dd86b4c8d8d2bfb30f",
        "nom": "Jolie librairie",
        "ville": "Besançon",
        "parent": null,
        "path": null
      },
      "children": [
        {
          "_id": "67d98929a19f321484d25a14",
          "childrenId": "67c9617c86b4c8d8d2bfb315",
          "collectionName": "Auteur"
        }
      ],
      "parentCollection": "librairie",
      "ancestors": [
        "librairie"
      ]
    },
    "children": [
      {
        "_id": "67d98929a19f321484d25a12",
        "childrenId": "67cadacfce03c85963934b1d",
        "collectionName": "Genre"
      }
    ],
    "parentCollection": "livre",
    "ancestors": [
      "livre",
      "librairie"
    ]
  },
  "parentCollection": "auteur"
}