extracting schema and models back from the dumped database - mongodb

I have dumped my project's mongo db database into my machine and want to extract the schema and models from the dumped database.
Is there any method in mongo db to get the schema back with the help of dumped database.
Any suggestions or feedbacks in this regard would be appreciated.

Is it not possible for you to restore the data into a MongoDB instances and look at the data again?
Not sure what you mean by schema, since MongoDB is very flexible on schema. From the nature of youu question, it looks like the schema is defined in mongoose and not exactly in MongoDB per-se and you are trying to reverse engineer that mongoose schema based on the data contained in the dump.
If you do not want to start a new instance and import the data, another option could be using bsondump utility that comes as part of MongoDB package to convert the BSON dump files to JSON format and analyzing them.

Related

how to get export data from oracle to mongoDB

I'm trying to change data from oracle data base to mongodb
the problem is :
my friend give me "file.sql" that have all the tables with data
and I want to get this data and add it to my mongo database
please I don't know how to do it
MongoDB is a NoSQL database, thus the SQL file will not help you.
Ask for CSV files, then you can use the mongoimport tool to import it into your MongoDB. Please note, usually it is a poor design when you migrate from Oracle to MongoDB and move tables to collections one-by-one. Typically in a MongoDB you will have much less collections than you have tables in Oracle.

Creating Models from MongoDB database

Is there any way to create models from MongoDB Database like Loopback has model discovery to reverse engineer database schemas into model definitions.
Because mongoDB database model is flexible it is not possible or not practical to create data model from it. Let me explain it this way. In SQL we create tables and columns manually or programmatically which does not change overtime. On the other hand in mongoDB you do not need to create tables and fields, when you invoke insert function on mongodb the data is stored in document model structure, which can be change over time depending on the data submitted for the next insertion.

mongodb - strategy from having relational DB CSV dump imported to highly denormalised mongodb documents

We want to migrate data to mongodb using a CSV files dump created out of a teradata. Data needs to be refreshed in mongodb every night from a fresh teradata csv dump
Approach we are thinking of is:
Get the CSV files exported out of relational db. They are going to be very similar to table structure in relational db
Import the CSV files into mongodb staging collections subsequently, which will be mirroring relational db structure in terms of being normalised. This may be done using say mongoimport in overnight batches. This is going to result in many collections as we are thinking to import each 'type' of CSV into its own collection e.g. Customers.csv and Accounts.csv will result in two respective collections of same name.
Create de-normalised collections out of staging collections, ready to be exposed to UI. Run some schema migration script, which queries the staging collections and creates more denormalised and fewer collections ready for use in the application UI.Eg, Customers and Accounts collections, after running migration script should result in a third collection say AccountCustomers collection where Each account doc has embedded customers array (denormalised and no need of joins when UI needs data)
Question: Is there a better strategy , as all above steps are expected to complete nightly, every night?
Question: Is mongoimport OK to use for importing the CSV files in nightly batches.
Question: What is the best way to migrate (denormalise) collections within the same mongo instance?Eg we have stagingdb having collections customers and accounts and we want to reach a state where we have proddb having collection accountcustomers

Do we have to create db and schema in mongodb before using it in node app using mongoose?

I am a beginner to MEAN stack,I have one doubt that if I want to use any database and schema in my app using mongoose .Is it important that the same database and schema should exist in mongo db before?
Mongodb is schema-less. In other words the schema lives in the application. So no separate schema definitely is required in Mongodb prior to using it. Both database and collection (schema) gets created on the fly while using it.
However if authentication is enabled in Mongodb, then the userid should have sufficient privilege to access the database and create collections within them.

Mongodb database schema diagram

How can I create a Mongodb database schema diagram?
I read the documentation in mongodb.org, but it is was not clear for me. Maybe Someone can help me with this, i have a db with embebed documents.
While MongoDB is a schemaless database there are a couple generators out there which do a nice job of creating a json schema representation. I find it particularly useful when looking for strategies for sharding or migrating. The output is very nice and the code is easily readable. I've personally adapted it to generate HTML tables and PDFs.
https://github.com/variety/variety
MongoDB has a flexible schema. Therefore, you can not list all fields unless fetching all documents in a collection. An alternative is defining schema in some kind of data structure(struct, associative array, class or other user defined structrue) or config file and then print it in diagram format.