I want to add array in database. I use ruby, sequel and postgresql, but question about true way, and not program realization. I see 3 path:
- Use special adapters. It help to save array like
[1,2,3,4]in db after some changes: in database it will look like"{1,2,3,4}". BUT after it I don't know how to convert this entry back to[1,2,3,4]without bullshits. - Convert array to json and save it to database. Array like
[1,2,3,4]will be look like"[1,2,3,4]". And I can easy convert back byJSON.parse. - Convert array by Marshal and save. Array
[1,2,3,4]will be look like"\x04\b[\ti\x06i\ai\bi\t", but it riskily, because data can be changed after ruby update (or I am wrong) Can anybody to tell about true way?