How do i export only the name of the columns from mongodb? - mongodb

I am new to mongodb and my task is to export metadata about all collections in a database. I know little about shell scripting and i am not able to understand the documents provided on mongodb website.
I am using Mongodb compass 4.2.14 and though i am able to export the collection, i am not able to just export the column names.
How do i export just the column names and also how to view the metadata?

In Compass GUI, select the Schema TAB, and click the Analyze button. This will show the data types for each field for a collection.
To get a copy of the schema, from the top-left menu, select the Collection -> Share Schema as JSON menu item. This will copy the schema to the Clipboard. You can then paste from the clipboard into any text file/editor of your choice.
Reference: Compass - Analyze Schema.

Related

How to copy all results from a query in Robo3T

I am using a query to pull a large chunk of fields from a MongoDB database in Robo3T. I want to copy all of the results of my query and paste them into an Excel Spreadsheet. However, when using the table view, Robo3T only lets me copy one value at a time and there is no option to copy when I have multiple values selected.
The only workaround I have found to this solution is to copy the raw JSON data but this is very inefficient as I want to only copy one column of the data. Is there a workaround to copy this data in Robo3T that I don't know about?
As you have mentioned you need to copy only one column of data you can select which column to get after the find query and get the results as an array.
Eg.
Collection columns: "_id","name","age"
Collection name: "employee"
db.getCollection("employee").find({age:20},{name:1})
This will return only id and names of the result
If you don't want id to then you need to specify _id:-1
db.getCollection("employee").find({age:20},{name:1,_id:-1})
If you want to combine all data into a single field (to copy effectively)
db.getCollection("employee").find({age:20},{name:1,_id:-1}).toArray()

How do you change a table's schema?

We have a MySQL Workbench project with two tabs (two schemas/two databases).
If we create a table in the first tab, it's attached to the schema
magikweb_dev_igcweb.
If we create a table in the second tab, it's attached to the schema
magikweb_dev_igcweb_archive.
If we copy-paste/duplicate a table from the first tab to the second tab, the resulting table remains in the first schema. How can you change a table's schema?
Each schema is linked with a specific database, so when we use the "Synchronize Model..." feature, it links all the tables properly.
Use the model tab. You can cut out a table from one schema tab and insert it into another.
The cut-and-paste method described in another answer works well for tables with no foreign keys, and for a reasonable number of tables.
An alternative that preserves foreign keys is to export the model as a SQL script, edit it, and then import the new script into a new model.
Using MySQL Workbench v6.3:
File -> Export -> Forward Engineer SQL Script
Carefully edit SQL script. Replace references to one schema with the other, for the tables you want to move. Do this both for CREATE TABLE commands and foreign key references.
File -> New Model
File -> Import -> Reverse Engineer SQL Script
Unfortunately you will then need to recreate any diagrams. But that can be straightforward if you have the original diagram as reference (take a screenshot or export it to PNG or PDF.)
Follow this simple steps (never miss step 4 and 5) :
Open Model Tab
Choose source schema. In my case, I want to copy table users from schema abc_develop_v1 to schema abc_develop_v2 then paste to diagram . So I choose schema abc_develop_v1, right-click table users then Copy 'users'
Go to the targeted schema. In my case is schema abc_develop_v2, right-click then Paste 'users'
Next, copy table users from schema abc_develop_v2. Right-click table users then Copy 'users'
Go to your diagram and Paste 'users'.
That's all. Your table is ready in your diagram with the right schema :-)
Notes: You can double check by double-click on the table in your diagram, and look at the right corner. It will show the Schema name.
I found a less painful way to do this.
Save and backup your diagram and your schema.
Display schema's name before table's names in diagram. This will make the next step easier.
Right-click on the tables which are on the wrong schema, and select "Copy SQL to clipboard". Paste the script in a new SQL window. Repeat for each table you want to migrate.
Edit the script to change the schema name. Watch for any miss in entries, the wrong schema might be a reference at any line. Mine was mydb, which I don't remember creating. Execute the script. Now you have the tables on the right schema.
Synchronize your model. Be sure to check "Update the model" for each missing table, otherwise, the tables will be deleted from the schema :)
Drag'n'drop the newly created tables into the diagram. Then remove the ones which are using the wrong schema. Tip: tables that are not in diagram won't display a dot next to their name.
Optionally, you can delete the faulty schema from the model so this never happens again. Be sure to know what you're doing first!

Tableau - Unable to replace data source in Tableau

I'm using MongoDB connected to Tableau using ODBC drivers..
I have connected to databases on Mongo.. Now i want to replace the data source with other databases.. b
I have query from customer saying that they want to see the same visualizations even after changing the data source to other which have json with same data.
Replacing a data source is rather simple. Add the query to the workbook - create an extract if needed - then return to a worksheet. Right-click on the data source's name and select "Replace data source...". This will give you a menu from which you choose which data source is to be used instead.
For other troubleshooting visit:
https://community.tableau.com/thread/151396

how to add new Fields into solr schema

I am doing data import from Mongo to Solr. For this I need to add new fields into the Solr schema. I am using solr server 5.1.0.
Schema.xml is not available in solrhome/server/solr/core/config directory so I copied one from solr-5.1.0\server\solr\configsets\basic_configs\conf to core\config and added fields into this.
Now when we start Solr server I get WARN message that I should remove the schema.xml file as this is now managed-schema. These fields should be moved to managed-schema file, but this didn't happen.
How Solr will move the database table to indexing. Does it convert each row into a document? Or I have to specify document structure somewhere?
How I can re index the data previously imported?
For Data import you need db-data-config.xml file where you will put your sql queries and configure it with SOLR For information about how to achieve the configuration go to this link
I have find a way to add the fields into schema. Please provide your input if there is any other proper way of doing it.
1. add schema.xml file into your solr/core1/conf directory.
2. copy all content of managed-schema into schema.xml
3. add the new fields into schema.xml.
4. delete the managed-schema.xml
5. restart the solr it will create a managed-schema.xml and will move schema.xml to scheam.bkp
References-
solrconfig.xml - Read the doc for schemaFactory tag.

Kentico Import Toolkit 8.1

I am currently using the Kentico Import Toolkit to create documents in the tree.
At this point, I have imported around 100 documents using the toolkit, and they are all located at the correct place in the tree. Now the issue/concern that I had was, as I have imported these documents, my spreadsheet has been updated, so extra fields and data were added, so how do I go about importing this extra data into the currently existing documents? Also just bear in mind I don't want other fields or data to be affected by this, as some of the documents were updated with some other content by the content editors using CMS Desk, which isn't available in the spreadsheet.
Import toolkit is not the right tool to achieve this task. Even if you select "Import new and overwrite existing pages" it'll overwrite most of your columns. Actually it only preserves system and id columns from the existing documents - all other columns get overwritten.
Either you can write a piece of custom code or you can try following:
Open SSMS and navigate to the coupled table of your page type (something like CONTENT_MyDocType). This is where your custom columns are stored.
Right click -> Edit top 200 rows
Click "Show SQL Pane"
Adjust the columns, ORDER BY and WHERE clause to match your excel file, re-run the query
Select desired rows in your excel file and copy them to clipboard
Paste the data in the SSMS
rocky is right, Import Toolkit is meant for importing complete objects, not partial/continuous update.
You could map the fields that you know are not changed in the spreadsheet to a SQL query selecting the value from the target database.
To achieve this, just insert #<target> at the beginning of the SQL select statement you will be mapping the field to.
It will be rather laborious though and it also requires certain knowledge about the nature of the spreadsheet changes.