0

I'm adding elements into an array("users") by using the $addToSet, but sometimes the array is null. Already tried to check if is null, and if it is use the $push, but I'm getting a The field 'users' must be an array but is of type null in document. Any ideas? This is the code I'm using:

    if(!userIsAssociated(campaign,user)){
    collection.updateOne(
            Filters.eq("_id", new ObjectId(id)),
            Updates.push("users", user));
    }
Poider12
  • 223
  • 3
  • 15

0 Answers0