mosql icon indicating copy to clipboard operation
mosql copied to clipboard

Help!!! How to deal with embed list to postgres by using mosql?eg:cus.utm.utm_source

Open HAPPYY opened this issue 12 years ago • 5 comments

  1. mongo's table
    table: cus
    column: utm
    embed column: utm_source
    etc:

db.cus.findOne(); { "status" : 5, "assign_status" : 1, "insure_for" : "s", "email" : "", "payment_scope" : null, "sex" : 1, "has_social_insure" : null, "updated_at" : ISODate("2013-05-14T08:27:06.400Z"), "created_at" : ISODate("2013-05-14T07:16:48.239Z"), "utm" : { "utm_source" : null, "utm_medium" : "organic", "utm_campaign" : "product", "utm_term" : null, "utm_content" : "floatlink_bottom(detail)", "ab_version" : "B Version", "_id" : 13659 }, "_id" : 13663 }

2.collections.yml

mongodb: cus: :columns: - id: :source: _id :type: INTEGER - status: :source: status :type: INTEGER - insure_for: :source: insure_for :type: VARCHAR(20) - email: :source: email :type: VARCHAR(20) - nick: :source: nick :type: VARCHAR(100) - payment_scope: VARCHAR(10) - sex: INTEGER - has_social_insure: BOOLEAN - updated_at: DATE - created_at: DATE - utm: VARCHAR(4000) :meta: :table: cus :extra_props: false

HAPPYY avatar May 23 '13 09:05 HAPPYY

You have to either create another table to map that embedded attribute or - which I think is easier - create a text column to store as JSON (that won't be useful if you need to use the data for SQL data analysis).

Sorry I can't be of more help...

lucasmartins avatar May 23 '13 21:05 lucasmartins

Thanks for help, we have already tried these methods what you said. (1).i created another table but how can i relate two tables when there aren't reference id? (2).create a text column it's really hard to group by some embedded attribute ,i have to join similar sq l sentences ,I can analysis simple situations but can't dig deep information...

hope more guys come here to discuss this question~

HAPPYY avatar May 24 '13 02:05 HAPPYY

mongodb: cus: :columns:

  • id: :source: _id :type: INTEGER
  • status: :source: status :type: INTEGER
  • insure_for: :source: insure_for :type: VARCHAR(20)
  • email: :source: email :type: VARCHAR(20)
  • nick: :source: nick :type: VARCHAR(100)
  • payment_scope: VARCHAR(10)
  • sex: INTEGER
  • has_social_insure: BOOLEAN
  • updated_at: DATE
  • created_at: DATE
  • utm_id: :source: utm._id :type: INTEGER
    • utm_source: :source: utm.utm_source :type: VARCHAR(100)
    • utm_medium: :source: utm.utm_medium :type: VARCHAR(100)
    • utm_campaign: :source: utm.utm_campaign :meta: :table: cus :extra_props: false

frankliu747 avatar May 28 '13 05:05 frankliu747

This doesn't work for me. Is there any way of dealing with multiple embeds yet?

shaneog avatar Jul 25 '14 17:07 shaneog

More documentation / examples of this being done would be welcome, at this point it seems like I'd be better off with manual migrations given the number of embedded models I have.

tirdadc avatar Aug 03 '15 14:08 tirdadc