Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:40:14+00:00 2026-05-28T19:40:14+00:00

I figured I would capitalize on DataMapper’s ability to store JSON objects to keep

  • 0

I figured I would capitalize on DataMapper’s ability to store JSON objects to keep my table nice and trim, but the documentation doesn’t clarify how one should go about querying on JSON values. I’m storing the scores for a basketball game like so:

{"NJN":[15,20,27,23,85],"CLE":[17,17,28,29,91]}

At the moment, to find games in which the Cleveland Cavaliers played, I’m doing this:

Game.all.reject { |g| !g.scores['CLE'] }

This is extremely slow and inefficient. Game.all(:scores['CLE']) throws a NoMethodError, so what is the proper syntax?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:40:15+00:00Added an answer on May 28, 2026 at 7:40 pm

    It is not intended that you search on the JSON. It is useful to be able to save the JSON in the DB, but if you need to search on it, you need to re-think your schema. DataMapper is not a silver bullet for good database design 😉

    Assuming your reasons for using JSON were simply convenience, you should move the JSON-encoded data to a separate model and map it using an association. You can write a migration to convert the records you have currently stored into the new format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I figured this would be simple, but being new to SSRS I'm not sure.
I figured this would be a quick google, but extensive searching hasnt yielded any
I figured I would ask... but is there a way to have the Get
Real Dumb question. I figured I would have gotten this straight by now, but
This might be one of those huh, why? questions, but I figured it would
I originally posted this question over at the Zend Forums but figured it would
New to using Instruments, but figured it would be good to help the performace
I've looked around but haven't found an answer so I figured i would give
Perhaps this is impossible, but I figured I would ask anyway. I'm working on
So this is my first module, so I figured there would be errors. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.