Skip to content

bserdar/blobstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blobstore for MongoDB

This is intended to be a simple replacement for binary object storage in MongoDB. GridFS does not play well with transactions, and it looks too much like a file system so using it for generic BLOB storage is usually inconvenient. This Go library provides a simple replacement for it.

Create a blob store using:

store := &blobstore.Store {
   Collection: coll,
}

Make sure indexes are created for the store. This will run once for the lifetime of the store.

store.EnsureIndex(context.Background())

You can simple write to a BLOB with its id. You have to generate an ID yourself:

	err := store.Write(context.Background(), blobID, bytes.NewReader(data))

And read from it:

	rd, err := store.Read(context.Background(), blobID)

You have to close the returned reader. You can close it midway if you are not interested in the whole stream.

About

Binary object storage for MongoDB, replacement for gridfs with transaction support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages