使用mgo存储嵌套结构

使用mgo存储嵌套结构,第1张

使用mgo存储嵌套结构

我认为使用

inline
字段标记是您的最佳选择。该氧化镁/ V2 /
BSON文档
状态:

inline     Inline the field, which must be a struct or a map,causing all of its fields or keys to be processed as ifthey were part of the outer struct. For maps, keys mustnot conflict with the bson keys of other struct fields.

然后,您的结构应定义如下:

type Cube struct {    Square `bson:",inline"`    Depth  int}

编辑

inline``mgo/v1/bson
如果您正在使用那个,也存在。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5564751.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存