$push operation fails on field set to null

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.5
    • Component/s: Querying
    • None
    • ALL
    • Hide
      db.getCollection('users').update(
        {"token.token":"21jpjg7pqdtigsdektmndqkobthdcktg"},
        {$push:{accounts:"test"}}
      )
      

      i run the command above in order to create an array field and the first element inside will be test but i get the error

      The field 'accounts' must be an array but is of type NULL in document

      i am really confused if i have to create a schema beforehand whats the point of using mongodb over some sql database
      i am using in Memory engine

      Show
      db.getCollection('users').update( {"token.token":"21jpjg7pqdtigsdektmndqkobthdcktg"}, {$push:{accounts:"test"}} ) i run the command above in order to create an array field and the first element inside will be test but i get the error The field 'accounts' must be an array but is of type NULL in document i am really confused if i have to create a schema beforehand whats the point of using mongodb over some sql database i am using in Memory engine
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      $push operator wont work

      Original Summary

      cannot run push if theres no array field

            Assignee:
            Unassigned
            Reporter:
            nikos efthias [X]
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: