mardi 27 janvier 2015

Import mongoDB file into Rails4 that uses Sqlite3

I have a very small rails 4 app that is using a sqlite3 database. I'm not very familiar with MongoDB, but I need to add some data from a preexisting mongoDB file into my Sqlite3 database. The mongoDB file is called seed.js and has something like



db.organizations.insert([{
"name" : "Steve",
"ben" : "114622",
"purchases": [
{ bandwidth: 100, measure: "m", cost: 67 },
{ bandwidth: 1000, measure: "k", cost: 85 }
]
},{
"name" : "Sally",
"ben" : "1123215",
"purchases": [
{ bandwidth: 1000, measure: "m", cost: 39 },
{ bandwidth: 1000, measure: "k", cost: 64 }
]
}]);


I've been trying to import this data to add it to my current Sqlite3 database and have, after some googling, ran into the Mongoid gem. But it seems, after reading the documentation and some tutorials, that mongoid is meant to simply replace my Sqlite3 database and not simply add to it?


How can I, with still keeping my main db as sqlite3, get the data from the mongo seed.js file?


Aucun commentaire:

Enregistrer un commentaire