MCPcopy
hub / github.com/mongodb/node-mongodb-native / rename

Method rename

src/gridfs/index.ts:232–239  ·  view source on GitHub ↗

* Renames the file with the given _id to the given string * * @param id - the id of the file to rename * @param filename - new name for the file

(id: ObjectId, filename: string, options?: { timeoutMS: number })

Source from the content-addressed store, hash-verified

230 * @param filename - new name for the file
231 */
232 async rename(id: ObjectId, filename: string, options?: { timeoutMS: number }): Promise<void> {
233 const filter = { _id: id };
234 const update = { $set: { filename } };
235 const { matchedCount } = await this.s._filesCollection.updateOne(filter, update, options);
236 if (matchedCount === 0) {
237 throw new MongoRuntimeError(`File with id ${id} not found`);
238 }
239 }
240
241 /** Removes this bucket's files collection, followed by its chunks collection. */
242 async drop(options?: { timeoutMS: number }): Promise<void> {

Callers 1

testFunction · 0.95

Calls 1

updateOneMethod · 0.45

Tested by 1

testFunction · 0.76