-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
translate string to array #13
Comments
Yes, you can do this using the before_save. Example: table "user" do
column "id", :key
column "first_name", :string
column "last_name", :string
column "created_at", :datetime
column "updated_at", :datetime
column "post_ids", :string # Post_ids looking like [1,2,8,19]
before_save do |row|
row.post_ids = eval(row.delete('post_ids')) unless row['post_ids'].blank?
end
end that should change the post_ids from a string to an array in MongoDB. However you're currently locked into that table, I'm planning to rewrite Mongify and might allow you to do something like: #NOT YET POSSIBLE
before_save do |row|
return if row['post_ids'].blank?
ids = eval(row.delete('post_ids'))
ids.each do |id|
self.db['posts'].insert(id: id) #using mongo-ruby-driver DSL
end
end Let me know if this helps. |
thanks though I must be doing something wrong here is the snippet from the translation file table "isodesign_product_data" do and here is the error On Nov 16, 2012, at 3:59 PM, Andrew Kalek <[email protected]mailto:[email protected]> Yes, you can do this using the before_save. Example: table "user" do that should change the post_ids from a string to an array in MongoDB. However you're currently locked into that table, I'm planning to rewrite Mongify and might allow you to do something like: #NOT YET POSSIBLE Let me know if this helps. — |
Sorry, It should be a
Hope that helps |
Thanks Sent from my iPhone On Nov 16, 2012, at 6:01 PM, "Andrew Kalek" <[email protected]mailto:[email protected]> wrote: Sorry, It should be a . (dot) not []. So you should be doing: row.dkhttp://row.dk = eval(row.delete('dk')) unless row.dk.blank? Hope that helps — |
Worked !! Thanks for mongify nice product Sent from my iPhone On Nov 16, 2012, at 6:01 PM, "Andrew Kalek" <[email protected]mailto:[email protected]> wrote: Sorry, It should be a . (dot) not []. So you should be doing: row.dkhttp://row.dk = eval(row.delete('dk')) unless row.dk.blank? Hope that helps — |
I'm glad it helped and thanks for the kind words! |
Will do ! I'm holding a mongo user group in jan here in Phoenix Sent from my iPhone On Nov 18, 2012, at 11:51 AM, "Andrew Kalek" <[email protected]mailto:[email protected]> wrote: I'm glad it helped and thanks for the kind words! — |
Hi Andrew , I am spreading the word ! Im having a MongoDB user group meeting Jan. 10 here in Tempe Arizona. By the way I see your in Toronto , That is my home town . I was the Ward in Ward Consulting. From: Andrew Kalek [[email protected]] I'm glad it helped and thanks for the kind words! — |
Hey Stephen, As for what to show, I think it's cool to show real data being moved, however it's hard to find data that's safe to show off. So you can check out the source code, under the tests, there is a small DB setup (or it might be being generated via code) of a user, preferences, posts and comments. You can try showing off that database. I might still have the files from what I did the 5 minute lighting talk with, if I find them, I'll provide you with a download link. Thanks again Andrew |
I can show real data I've got a project of my own ill use. Sent from my iPhone On Dec 10, 2012, at 9:21 AM, "Andrew Kalek" <[email protected]mailto:[email protected]> wrote: Hey Stephen, As for what to show, I think it's cool to show real data being moved, however it's hard to find data that's safe to show off. So you can check out the source code, under the tests, there is a small DB setup (or it might be being generated via code) of a user, preferences, posts and comments. You can try showing off that database. I might still have the files from what I did the 5 minute lighting talk with, if I find them, I'll provide you with a download link. Thanks again Andrew — |
Andrew the Phoenix MongoDB user group is Thursday next week. please send me any material you want me to present ASAP Thanks On Dec 10, 2012, at 9:21 AM, Andrew Kalek <[email protected]mailto:[email protected]> wrote: Hey Stephen, As for what to show, I think it's cool to show real data being moved, however it's hard to find data that's safe to show off. So you can check out the source code, under the tests, there is a small DB setup (or it might be being generated via code) of a user, preferences, posts and comments. You can try showing off that database. I might still have the files from what I did the 5 minute lighting talk with, if I find them, I'll provide you with a download link. Thanks again Andrew — |
Hey, I've reviewed my stuff and I don't have anything left from that video, Andrew Kalek On Fri, Jan 4, 2013 at 3:57 PM, Stephen Ward [email protected]:
|
Hello Anlek, Is it possible to migrate whole table with out specifying column names in translation.rb file? table "Test". |
Hey @Komalil, Good luck, |
Hi Andrew,
Thanks for the email..
We need to migrate some of the mysql tables to mongo as per client
requirement. But mysql is having 4000+ tables. If i use below command, all
4000+ tables will be translated. My requiremnt i need to pick some of the
tables do the translation.
mongify translation database.config > translation.rb
I have referred table.rb file, i have seen below commnad in that:
table "table_name" # Does a straight
copy of the table
table "table_name", :embed_in => 'users' # Embeds table_name into users,
assuming a user_id is present in table_name.
the above commands i have tried in translation.rb file like:
table <mysql table name>
table <mysql table name>,:embed_in=> <Mongo collection name>
But it does not work.
Would you please suggest any required solution, how i need to migrate
specific tables to monog from out of mysql 4000+ tables?
Thanks in advance.
Regards,
Komali
…On Mon, Mar 27, 2017 at 6:18 AM, Andrew Kalek ***@***.***> wrote:
Hey @Komalil <https://github.com/Komalil>,
It is not an issue but a feature. Mongify ignores any columns you don't
specify in the translation (as it wouldn't know how to translate them).
I'm not exactly sure why you don't want to use a translation, you can
generate the translation table automatically via the mongify translation
database.config > translation.rb command.
Good luck,
Andrew
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AZQB6RfaBFbG_zY-G2aDzo2_fxEB1yagks5rpwdUgaJpZM4AQghg>
.
|
I'm going to reply to this in #133 as it's more relevant there. |
in the mysql db I have an array stored as a string example "[3.3,3.2,3,2.8]"
i would like to translate that so its stored just as an array {myArray: [3.3,3.2,3,2.8] }
is this possible ?
The text was updated successfully, but these errors were encountered: