4 ms·
How does FerretDB represent documents in Postgres? JSONB, or something custom? How does it handle the mismatch between jsonb and bson? In particular: * more s
by CodesInChaos 5y ago
How does FerretDB represent documents in Postgres? JSONB, or something custom?
How does it handle the mismatch between jsonb and bson? In particular:
* more scalar types, including blobs. One hack I could think of is using ISO 8859-1 encoding instead of UTF-8, which can act as a pseudo-blob.
* preserved field order
- PeterZaitsev 5y agoFerretDB is very early in its development phase so things can change. Right now it uses JSONB but enhances object with additional meta data, such as field order for example.
- aleksi 5y agoFerretDB co-founder there. The order of fields is maintained by adding a special field with keys in the original order. For example, `{z: 1, a: {y:2, x:3}}` is stored as `{"a":{"x":3,"y":2,"$k":["y","x"]},"z":1,"$k":["z","a"]}`. Additional types are stored as objects with special fields too. For example, binary values are stored as `{"$b": "<base 64 string>", "s": <subtype number>}`. The full mapping is there: https://github.com/FerretDB/FerretDB/blob/b7e8240607e043a85816481b1a73730fda0780e6/internal/bson/bsontype.go#L17-L32 https://github.com/FerretDB/FerretDB/blob/b7e8240607e043a858...