mongo-go-driver-protobuf
mongo-go-driver-protobuf copied to clipboard
This is extension for MongoDB Go driver adds support for Google protocol buffers types
mongo-go-driver-protobuf
This is extension for officional MongoDB Go driver adds support for Google protocol buffers types.
- Description
- Links
- Requirements
- Installation
- Usage example
Description
It contains set of BSON marshal/unmarshal codecs for Google protocol buffers type wrappers, Timestamp and MongoDB ObjectID:
BoolValueBytesValueDoubleValueFloatValueInt32ValueInt64ValueStringValueUint32ValueUint64ValueTimestampObjectID
Links
- Official MongoDB Go Driver: https://go.mongodb.org/mongo-driver
- Google protocol buffers types (wrappers): https://github.com/golang/protobuf/blob/master/ptypes/wrappers/wrappers.proto
- Google protocol buffers Timestamp type: https://github.com/golang/protobuf/blob/master/ptypes/timestamp/timestamp.proto
- MongoDB ObjectID type: https://github.com/mongodb/mongo-go-driver/blob/master/bson/primitive/objectid.go
- MongoDB ObjectID my proto wrapper: https://github.com/amsokol/mongo-go-driver-protobuf/blob/master/proto/mongodb/objectid.proto
Requirements
- Google protocol buffers version
proto3 - Official MongoDB Go Driver RC1 or higher
Installation
Installing using go get:
go get -u github.com/amsokol/mongo-go-driver-protobuf
or you don't need to do anything manually if you are using Go modules. Go modules installs necessary packages automatically.
Usage example
First install protoc-gen-gotag to make available Go language tags for proto messages
go get -u github.com/amsokol/protoc-gen-gotag
Next
- Create free Altas mini MongoDB instance
- Create
experimentsdatabase - Create
protocollection intoexperimentsdatabase - Run this example