如何在 MongoMapper 中使用缩写字段名

发布于 2024-12-27 04:58:11 字数 272 浏览 0 评论 0原文

我正在使用 MongoMapper 并试图想出一种使用缩写字段名称的方法。我想将键保留为简单的英语,但将字段名称存储得很短(例如“name”映射到“_n”)。我注意到一场对话,但最终结束了(https://github.com/jnunemaker/mongomapper/pull /351),我想知道是否有人有一个如何实现这一点的例子。如果有任何反馈,我将非常感激!

I'm using MongoMapper and am trying to come up with a way to use an abbreviated field name. I want to keep the keys as plain english but have the field names stored short (e.g. "name" maps to "_n"). I noticed a conversation but it ended up closed (https://github.com/jnunemaker/mongomapper/pull/351) and I was wondering if anybody has an example of how to accomplish this. I'd be extremely grateful for any feedback!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光①夏 2025-01-03 04:58:11

与该对话相关的是另一个拉取请求,#353。它还没有被撤回,但我猜它很可能会被撤回,它可能只是被维护者忘记了。

拉出后,您的案例将如下所示:

class User
  include MongoMapper::Document
  key :name, String, :abbr => :_n
end

我建议在 #353 上发表评论说您正在寻找该功能。

Related to that conversation is another pull request, #353. It hasn't been pulled yet but I'm guessing it likely will be, it simply may have been forgotten by the maintainers.

When pulled, your case will look like:

class User
  include MongoMapper::Document
  key :name, String, :abbr => :_n
end

I recommended leaving a comment on #353 saying that you were looking for that feature.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文