codingjoe
codingjoe

Reputation: 810

MongoDB not inserting all documents

I am throwing the towel. I cannot understand why all my inserts are not showing in MongoDB.

I am trying to insert 8 documents, but only 5 are showing. My insert code:

db.mycollection.insertMany(
   [  {
    "_id": "e89c4c7a-bfdc-4433-bf68-2b3ea4deaad6",
    "name": "Dunn England",
    "isActive": false,
    "balance": "1,505.70",
    "picture": "http://placehold.it/32x32",
    "age": 25,
    "eyeColor": "brown",
    "gender": "male"
  },
  {
    "_id": "4b5cc8e8-6683-4dd9-a0c3-dd683c41c32f",
    "name": "Elizabeth Cunning",
    "isActive": false,
    "balance": "505.70",
    "picture": "http://placehold.it/32x32",
    "age": 19,
    "eyeColor": "brown",
    "gender": "female"
  },
  {
    "_id": "808259cb-0ea3-4424-b626-c147655625fc",
    "name": "Gabrielle Dane",
    "isActive": true,
    "balance": "5505.70",
    "picture": "http://placehold.da/32x32",
    "age": 38,
    "eyeColor": "blue",
    "gender": "female"
  },
  {
    "_id": "26a0278a-d825-42f9-a697-47a53f69e0c5",
    "name": "Renee Morrow",
    "isActive": true,
    "balance": "2,022.81",
    "picture": "http://placehold.it/32x32",
    "age": 24,
    "eyeColor": "green",
    "gender": "female"
  },
  {
    "_id": "d631ff57-c77c-4447-bad9-37b2147ed18f",
    "name": "Jake Roberts",
    "isActive": false,
    "balance": "6022.81",
    "picture": "http://placehold.it/32x32",
    "age": 24,
    "eyeColor": "green",
    "gender": "male"
  },
  {
    "_id": "48b7a108-07c9-4107-aed8-637756caa430",
    "name": "Urmina Roberts",
    "isActive": true,
    "balance": "7,6022.81",
    "picture": "http://placehold.it/32x32",
    "age": 24,
    "eyeColor": "green",
    "gender": "female"
  },
  {
    "_id": "3a75d9dc-ef66-452b-9e12-9dcda2a33977",
    "name": "Emily Waters",
    "isActive": false,
    "balance": "76022.81",
    "picture": "http://placehold.ww/34x34",
    "age": 44,
    "eyeColor": "brown",
    "gender": "female"
  },
  {
    "_id": "b01a9244-28b5-4c89-90d5-70fb1ec573e2",
    "name": "Scott Turner",
    "isActive": true,
    "balance": "1,894.19",
    "picture": "http://placehold.dk/32x32",
    "age": 88,
    "eyeColor": "green",
    "gender": "male"
  }]
)

Even the acknowledged message states having inserted 8 documents.

acknowledged: true,
  insertedIds: {
    '0': 'e89c4c7a-bfdc-4433-bf68-2b3ea4deaad6',
    '1': '4b5cc8e8-6683-4dd9-a0c3-dd683c41c32f',
    '2': '808259cb-0ea3-4424-b626-c147655625fc',
    '3': '26a0278a-d825-42f9-a697-47a53f69e0c5',
    '4': 'd631ff57-c77c-4447-bad9-37b2147ed18f',
    '5': '48b7a108-07c9-4107-aed8-637756caa430',
    '6': '3a75d9dc-ef66-452b-9e12-9dcda2a33977',
    '7': 'b01a9244-28b5-4c89-90d5-70fb1ec573e2'

local> db.mycollection.countDocuments()
5

But only 5 documents are present. What am I missing? I am really not seeing why and where the problem is...it is driving me nuts :/

It is the same problem, even when I use MongoDB Compass GUI.

Upvotes: 0

Views: 117

Answers (1)

codingjoe
codingjoe

Reputation: 810

The problem was in the way my collection was configured. It was capped with a size and amount of documents limit.

Upvotes: 0

Related Questions