-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gridfs implementation #10
Comments
Hi @njordr, I'm afraid I've limited experience with GridFS having only used on one project and that was using MongoEngine. They provide a Do you have any thoughts or an example snippet of pseudo code on what the interface for GridFS should look like in MongoFrames? |
I wondering if gridfs could be managed as a SubFrame, so when a field is a gridfs element it could be implemented as a SubFrame class (GridFrame class? :) ) |
Beyond the Id of the file what else would the SubFrame/Embedded document store, if it's just the Id this seems like we'd be creating structure for a single field? One option I thought might be viable be is to look for a special postfix to attribute names, for example: from mongoframes import Frame
class Product(Frame):
_fields = {
'sku',
'name',
'desc',
'price',
'images',
'manual'
}
product = Product(
sku='A123',
name='Mouse',
desc='Squeaks a lot',
price=500
)
# Store a single file using GridFS
with open('mouses_are_great.pdf') as f:
product.manual_fs.put(f.read())
# Store multiple files using GridFS
pics = []
for pic in ['mouse_posing', 'mouse_scoffing_cheese', 'mouse_trapped']
with open(pic + '.jpg') as f:
pics.append(f.read())
product.images_fs.put_many(pics)
# Save the product
product.insert()
# Retrieve the manual
manual = product.manual_fs.get()
# Retrieve the images
images = product.manual_fs.get_many() In this scenario only the Id of the file is saved, by default this would use the same database to store the GridFS files as the Frame uses to store it's data, we'd need to figure out a way to make this easy to override - but before I look at that further what are your thoughts on this? |
The scenario proposed is great, really :) |
Hi.
Any chance to have gridfs implemented? Just to not call functions from pymongo directly
Thanks
The text was updated successfully, but these errors were encountered: