Hi, my use case is following:
Part of the data in my application is stored in the KV database(e.g. LevelDB) and part is stored in the file. And data structure is like:
type Data struct{
Version []byte `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
Number uint64 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"`
Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Content []byte `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
}
The actual data structure is more complicated than listed here. Field `Number` is unique and monotonically increasing. So in the KV database, Key is `Number`, Value is the result of Data instance protobuf marshal.
And now, I want to store part of fields mentioned above to MongoDB, so that supports "SQL" query in the MongoDB, and then get the final detailed result from KV database using the primary key of document. The document structure is like:
type Doc struct{
Number uint64 `bson:"_id"` // This is primary key.
Timestamp int64 `bson:"timestamp"` // The reason why stores this field is that user can query data within a specified time range,
// and KV database only support key query.
}
`Number` is the primary key, and I suppose it may exceed math.MaxInt64 one day. Another requirement is that user can specify the start position of querying through giving a `Number` value, so I need to compare `Number`.
In conclusion:
1. In my application developed in Go, `Number` should be uint64 type.
2. I have to store `Number` into MongoDB, and will do comparisons for `Number`.
Thanks, sorry for my english,
Sammy
在 2020年3月5日星期四 UTC+8上午10:33:30,Divjot Arora写道: