Closed andrey-tech closed 1 year ago
@andrey-tech this sounds like a good idea! While we're tweaking UploadOptions
we could also add this missing options
@andrey-tech would you be up for a PR?
We need this feature too! A nice improvement would be converting values to a database via mapping type. With the @andrey-tech tweak, we need to self-convert the UUID object to the Binary object.
$uploadOptions->_id = new \MongoDB\BSON\Binary($uuid->getBytes(), Binary::TYPE_UUID);
with mapping
<id field-name="uuid" strategy="NONE" type="ramsey_uuid_binary" />
@malarzm Yes, https://github.com/doctrine/mongodb-odm/pull/2489
Feature Request
Summary
I would like to have a way to set custom file document identifier (
_id
) for GridFS document, when I insert a new file into GridFS bucket by methodsuploadFromFile()
oruploadFromStream()
of GridFSRepository interface.This important functionality is required when migrating from MongoDB using old
doctrine/mongodb-odm
v1.x to a new MongoDB usingdoctrine/mongodb-odm
v2.x. I need to have the same document identifiers (_id
) for GridFS documents in old and new MongoDB.Used MongoDB library (
mongodb/mongodb:^1.2.0
) supports this functionality in methoduploadFromStream()
of class Bucket.I suggest to add the parameter
_id
as a new property of class UploadOptions and update methodprepareOptions()
of class DefaultGridFSRepository to support new option_id
. So, no big changes are required.