BSON::Proxy Proxy content from/to another collection
I would like a mongodb data type, called
BSON::Proxy # not indexable or searchable
Which would hold the value of another collection & id.
IE:
BSON::Proxy({database: "this_one", collection: "blobs", _id: "123"})
This would allow my code to request a field that would be used for reading ONLY IF REQUESTED in the projection.
Example record:
{
id: "abc",
username: "test user",
blob: BSON::Proxy({database: "thisone", collection: "blobs", _id: "123"})
age: 50
}
db.collection.find(query, projection, options)
db.users.find({_id: "abc"}) # returns all fields except blob.
db.users.find({_d: "abc", { _id: true, username: true, blob: true, age: true }}) # returns all fields including blob.
This would allow me to store BLOBS with the document that are accessable only on demand and would not adversely affect performance
when searching as the BLOB would not be loaded with the document
Under the hood the BLOB would be stored in another collection tables.
This maximizes scan and queries but allows for the simplification of a schema for storing large blocks of data.
No FK validation would be expected.