• Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      According to the docs: Currently the valid types in Mongoid are: Array, Boolean, Date, DateTime, Float, Integer, String, Time and any object that inherits from Mongoid::Document.

      Apologies if I'm missing something obvious, but: How do I persist a document with a hash as a field? If I can't do this, is there a reason?

      The two workarounds I can think of are: I could create a Mongoid::Document with a field for every possible key the hash might have, and use it instead (but this would grow unwieldy if there are hundreds of possible keys); or I could convert the hash to JSON, store it in a string field, and then convert it back as needed. The latter option would be easier, but would make no sense (why would you store a JSON string in MongoDB?) and would prevent me from making MongoDB queries within the hash.

      Suggestions?

            Assignee:
            Unassigned Unassigned
            Reporter:
            trevorburnham Trevor Burnham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: