async updateOne()

in lib/Collection.ts [50:60]


  async updateOne(document: string, newObj: any, partial: boolean) {
    const newValue = JsonEncoder.decode(newObj);
    
    // TODO: For now it makes it impossible to remove fields from object with a projection
    const update = partial ? { '$set':newValue } : JsonEncoder.decode(newValue);
    await this._collection.replaceOne({
      _id: new MongoDb.ObjectId(document)
    }, update);
    
    return JsonEncoder.encode(newValue);
  }