1

I have an array of hashes from an api that I want to store in a database. This data is just a list of names that are always going to be the same so I wanted to remove the api call to reduce load times. How can I store this data? Do I have to make a model of it?

The data looks like this:

[{"id":"30","name":"Mike"},
 {"id":"57","name":"Dave"},
 {"id":"9","name":"Kevin"},
 ....
 {"id":"20","name":"Kyle"}]

Would I be able to open a db viewer/editor tool and just type the data in?

1 Answer 1

2

It looks to be structured in a way that would make it very suitable as a new model in the application. You don't have to do that, but for the most conventional storage form, that would be my choice.

Sign up to request clarification or add additional context in comments.

5 Comments

I agree, it would be easy to add a model of it, but I added an edit to the original question: Would I be able to open the db in a db editor and just type the data in?
Yes, but if this is part of an application that you want to deploy another time then including the data load as part of a migration would probably be better.
I highly recommend the usage of a Model in this case. The model is flexible, you can add extra methods on the model. Methods like a search function on the name attribute of each hash, for example, or a sorting function, etc...
@MrYoshiji made it a community wiki if you want to add thoughts in.
can you post a link to that wiki? i can't find it but im assuming im just looking in the wrong place

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.