3 ms·
FerretDB 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
by aleksi 5y ago
FerretDB 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...