Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-57436

mongoDB insert unwanted value in a first order array entry when I insertOne, updateOne or save

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • ALL
    • Hide

      What do I use :

      • MongoDb Atlas
      • NodeJs Drider 3.6.9

      Collection params :

      • _id index
      • JsonSchema :

      {
        $jsonSchema: {
          bsonType: 'object',
          required: [
            'property_name'
          ],
          properties: {
            property_name: {
              bsonType: 'string'
            },
            keywords: {
              bsonType: 'array'
            },
            description: {
              bsonType: 'object',
              required: [
                'en',
                'fr'
              ],
              properties: {
                en: {
                  bsonType: 'string'
                },
                fr: {
                  bsonType: 'string'
                }
              }
            },
            alternative_meta: {
              bsonType: 'object',
              properties: {
                meta_description: {
                  bsonType: 'string'
                },
                last_scrapp_date: {
                  type: [
                    'number'
                  ]
                },
                last_data_validation: {
                  type: [
                    'number'
                  ]
                }
              }
            },
            product_details: {
              bsonType: 'object',
              properties: {
                mark: {
                  bsonType: 'string'
                },
                name: {
                  bsonType: 'string'
                },
                license: {
                  bsonType: 'string',
                  'enum': [
                    'proprietary',
                    'opensource'
                  ]
                },
                distribution: {
                  bsonType: 'array'
                },
                type: {
                  bsonType: 'string',
                  'enum': [
                    'saas',
                    'software',
                    'toolkit',
                    'library',
                    'code',
                    'api'
                  ]
                },
                type_history: {
                  bsonType: 'array'
                }
              }
            },
            links: {
              bsonType: 'object',
              required: [
                'url',
                'icon'
              ],
              properties: {
                icon: {
                  bsonType: 'string'
                },
                url: {
                  bsonType: 'string'
                },
                download: {
                  bsonType: 'string'
                },
                login: {
                  bsonType: 'string'
                }
              }
            },
            pricing: {
              bsonType: 'object',
              properties: {
                price_url: {
                  bsonType: 'string'
                },
                price: {
                  bsonType: 'string',
                  'enum': [
                    'fee',
                    'free',
                    'freemium'
                  ]
                },
                price_from: {
                  type: [
                    'string',
                    'null'
                  ]
                },
                price_detail: {
                  bsonType: 'array'
                }
              }
            },
            opencorpdata: {
              bsonType: 'object'
            },
            language: {
              bsonType: 'array'
            },
            service_locations: {
              bsonType: 'array'
            },
            wikipedia: {
              bsonType: 'object'
            },
            youtube: {
              bsonType: 'object'
            },
            twitter: {
              bsonType: 'object'
            },
            instagram: {
              bsonType: 'object'
            },
            purpose: {
              bsonType: 'array'
            },
            integration: {
              bsonType: 'array'
            }
          }
        }
      }
      

      Sequence :

      1. API call to delete a document in the collection
      2. API call to instert a new document in the collection

      Driver code :

      1. In the API call

       

      Show
      What do I use : MongoDb Atlas NodeJs Drider 3.6.9 Collection params : _id index JsonSchema : { $jsonSchema: { bsonType: 'object' , required: [ 'property_name' ], properties: { property_name: { bsonType: 'string' }, keywords: { bsonType: 'array' }, description: { bsonType: 'object' , required: [ 'en' , 'fr' ], properties: { en: { bsonType: 'string' }, fr: { bsonType: 'string' } } }, alternative_meta: { bsonType: 'object' , properties: { meta_description: { bsonType: 'string' }, last_scrapp_date: { type: [ 'number' ] }, last_data_validation: { type: [ 'number' ] } } }, product_details: { bsonType: 'object' , properties: { mark: { bsonType: 'string' }, name: { bsonType: 'string' }, license: { bsonType: 'string' , 'enum' : [ 'proprietary' , 'opensource' ] }, distribution: { bsonType: 'array' }, type: { bsonType: 'string' , 'enum' : [ 'saas' , 'software' , 'toolkit' , 'library' , 'code' , 'api' ] }, type_history: { bsonType: 'array' } } }, links: { bsonType: 'object' , required: [ 'url' , 'icon' ], properties: { icon: { bsonType: 'string' }, url: { bsonType: 'string' }, download: { bsonType: 'string' }, login: { bsonType: 'string' } } }, pricing: { bsonType: 'object' , properties: { price_url: { bsonType: 'string' }, price: { bsonType: 'string' , 'enum' : [ 'fee' , 'free' , 'freemium' ] }, price_from: { type: [ 'string' , 'null' ] }, price_detail: { bsonType: 'array' } } }, opencorpdata: { bsonType: 'object' }, language: { bsonType: 'array' }, service_locations: { bsonType: 'array' }, wikipedia: { bsonType: 'object' }, youtube: { bsonType: 'object' }, twitter: { bsonType: 'object' }, instagram: { bsonType: 'object' }, purpose: { bsonType: 'array' }, integration: { bsonType: 'array' } } } } Sequence : API call to delete a document in the collection API call to instert a new document in the collection Driver code : In the API call  

    Description

      When I insert a document in a collection on mongoDB Atlas via the nodeJs driver some array gets new entry from the previouly delete. Sometime it is null or a duplicate. It would not happen on all the entry of array type. This concerne as far as I know text items and object items.

       

      Attachments

        Activity

          People

            edwin.zhou@mongodb.com Edwin Zhou
            projetcreasup@gmail.com Network Platform
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: