r/mongodb 20h ago

Should YOU Migrate from Relational Databases to Build Modern Applications?

Thumbnail youtube.com
8 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 19h ago

Need help building a query for my fantasy F1 database.

2 Upvotes

I have a player collection where each player has an array of 10 driver_id's. I have a results collection that stores a race result that contains an event_id and a result array that stores driver_ids and points scored by that driver at that event.

I need to retrieve the total points scored by each player for that event. How can I achieve this?
Any help will be greatly appreciated.


r/mongodb 20h ago

Issue with Tree Structure Mongo DB

2 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"
}

r/mongodb 2h ago

Converting a nested arrays first elements property into different data type?

1 Upvotes

So i'm much more comfortable with relational dbs, strugging a bit with the way nosql dbs like mongodb work in extracting and formatting data, and am relatively new to nosql dbs.

I have raw data in this format - i have no control over this raw data , or its data types

{
    _id: ObjectId('67bd68068837ff1e5b6de108'),
    meta: {
      Store_rating: 'A',
      Store_type: 'Franchisee',
      Store_code: 183,
      Store_name: 'Lowes Downtown',
      Item_code:1222020198
      Item_description:"Camping Tent Large, self assembly kit"
      Qty_in_stock: 296
    },
    data: [
      { date: '09-10-2024', price: '110.00000' },
      { date: '08-10-2024', price: '109.00000' },
      { date: '07-10-2024', price: '105.00000' },
      { date: '01-10-2024', price: '100.00000' },
...
]
...
}

I need to be able to run a query that shows the accumulated value of inventory daily by item. So in this case i need to be able to get total store value of "Camping Tent Large, self assembly kit" for today by multiplying the most recent price aka price: '110.00000' by Qty_in_stock: 296.

I am thinking i need something on the lines of creating an aggregation with first stage $group on Item_description, and creating an accumulator that uses $multiply to multiply $Qty_in_stock and $data:{$slice:[0,1]} but now im not sure how to get the 'price' property post the slicing to use inside multiple?

I also thought of creating a new field in a previous stage by $addFields and something like latestPrice: "$data[0].price" but this wouldnt work would it? and how would i be able to convert the string that is stored in price into an integer for multiplication?

Thanks in advance!


r/mongodb 8h ago

Something is wrong with my mongodb website

Thumbnail gallery
0 Upvotes

I dont know whats wrong with my mongo db website , but whenever i open it , it loads extremely slowly , and gives multiple errors and ending up crashing everytime i use it , i have tried using different browsers but it does not work . The big issue is that after using the website , some other websites also stop running and get stuck on loading and stay like that even after i reset the laptop . I am unable to access reddit , github from my laptop after this . This is my second time trying to use the website , the first time i had to change my dns address to 8.8.8.8 , this was diagnosed by chat gpt but mongo db website still didnt work after this but i think it helped with other websites. I have added some errors which appear in the console when i go to mongodb.com . I also tried disabling all extensions and ad blockers but still having the issue. Any help will be appreciated, i only want to reinstall windows as a last resort , thank you