in Education by
I want to build a relatively simple web app using Pharo, Voyage and MongoDB + TeaPot. Before I start the project I did a lot of research and one question remains: How do I initially upload a bunch of data into the MongoDB? I basically have the data in CSV format. Do I have to program an importer in Smalltalk that does that? If I were to do it without smalltalk it would be missing all the object IDs etc. How do you go about things like that? Thanks, Henrik JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
If you have data in CSV format, then I would recommend creating a simple importer. You could use NeoCSV and then save it via Pharo. I presume you know how to setup Mongo repository (@workspace) do: | repository | repository := VOMongoRepository host: VOMongoRepository defaultHost database: 'MyMongoDb'. VORepository setRepository: repository. First create your two class methods for Voyage: Kid class >> isVoyageRoot ^ true "instances of this object will be root" Kid class >> voyageCollectionName ^ 'Kids' "The collection name in MongoDB" The Kid class should have firstName(:), surname(:), age(:) accesors and instance variables of the same name. Then simply have a reading from CSV and then saving it into mongoDB: | personalInformation readData columnName columnData aKid | "init variable" personalInformation := OrderedDictionary new. "emulate CSV reading" readData := (NeoCSVReader on: 'firstName, surname, age\John, Smith, 5' withCRs readStream) upToEnd. columnName := readData first. columnData := readData second. "Repeat for as many number of columns you may have" 1 to: columnName size do: [ :index | personalInformation at: (columnName at: index) put: (columnData at: index) ]. aKid := Kid new. "Storing Kid object information" personalInformation keysAndValuesDo: [ :key :value | aKid perform: (key asString,$:) asSymbol with: value "For every column store the information into a Kid object (you have to have accessors for that)" ]. aKid save "Saving into mongoDB" This is only to give you rough idea To query in your MongoDB do: db.Kids.find() You should see the stored information. Disclaimer: Even thou the code should be fine, I did not have time to actually test it on mongoDB.

Related questions

0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Im facing a litle problem in Deserializing BsonDocuments type, I couldn't find the reason, but I have some ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I'm trying to make a form-maker with Node.Js and MongoDB but confused about the data structure. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Currently I am working in dev env on my local machine where I am storing passwords in plain text using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 6, 2022 in Education by JackTerrance
0 votes
    I have a Post model that has a likes array that contains the ObjectId of the user that liked the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I tried mongo replica sets for the first time. I am using ubuntu on ec2 and I booted up three instances ... replicate across machines? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I tried reading from various sources but I am still not very clear about their difference. What majorly seperates Mongodb and Hadoop? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Compare SQL databases and MongoDB at a high level....
asked Apr 13, 2021 in Technology by JackTerrance
0 votes
    What I'm trying to do here is use the 2 functions but I don't know how to use both of them ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do here is use the 2 functions but I don't know how to use both of them ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Here is my data: { { "_id" : ObjectId("623a92139e19f99295167786"), "headline" : "headline1", " ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm getting unexpected results for getting the collections between two columns. I have this simple collection: ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm getting unexpected results for getting the collections between two columns. I have this simple collection: ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
...