在符号中获取带有符号的哈希作为mongo的键 [英] Getting hash with symbol as keys for mongo in rails

查看:54
本文介绍了在符号中获取带有符号的哈希作为mongo的键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mongo红宝石驱动程序似乎将结果放入带有字符串作为键的哈希中.有没有办法告诉它将密钥转换为符号?

The Mongo ruby driver seems to get put your results into a hash with strings as keys. Is there a way to tell it to convert the keys into symbols instead?

推荐答案

根据 FAQ ,即使Mongo中存在符号类型,并且您可以将符号存储在值中,但BSON格式仍指定键必须为字符串.

According to the FAQ, Even though there is a symbol type in Mongo, and you can store symbols in values, the BSON format specifies that keys must be strings.

这篇关于在符号中获取带有符号的哈希作为mongo的键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆