Can I store arrays in hstore with Rails

前端 未结 3 1328
刺人心
刺人心 2020-12-17 09:20

I want to save data like this:

User.create(name:\"Guy\", properties:{url:[\"url1\",\"url2\",\"url3\"], street_address:\"asdf\"})

Can I do so in

3条回答
  •  囚心锁ツ
    2020-12-17 10:13

    My 2 cents to Mu's answer. I'm posting this as an answer cause I don't have enough reputation to add a comment.

    JSON is becoming the go-to solution for storing "complex" data.

    Oleg Bartunov--one of the authors of hstore--himself stated that there is no advantage using hstore over JSON and he encourages people use jsonb.

    On Mar 23, 2014 jsonb, a structured format for storing json, was formally introduced in the pgsql development mailing list.

    On May 15, 2014 JSONB was listed in the PostgreSQL 9.4 Beta 1 release announcement.

    JSONB: 9.4 includes the new JSONB "binary JSON" type. This new storage format for document data is higher-performance, and comes with indexing, functions and operators for manipulating JSON data.

提交回复
热议问题