TmongoDbInput schema not retrieving JsonArray Properly - mongodb

I'm trying to retrieve below mongo collection data using TalendOpenStudio for Big Data 7.2.
T
{
"id": "5b69b66d3dae73000fa39440",
"data":"Testing"
"products": [{ "orderid":"1234"
}],
"createDate": "2018-08-07T15:10:37.570Z",
"updateDate": "2018-08-09T16:09:46.621Z"
}
I'm able to get Id,data but when i try to get products i'm unable to get the data. On top of it i'm getting products as below
[Document{{"orderid"="1234"}}] this is blocking me for parsing it as json. Can someone help. I think its a basic mistake but as i said i'm new to Talend OS for Big Data
If anyone has already parsed this , can you please share the schema to be defined for products arraylist in talend and how they parsed id,data,products.
I tried using extractjson fields, using mongoschema from repository still no luck.

Looks like its a mongo driver(3.5.x) issue. Here are more details.
https://community.talend.com/t5/Design-and-Development/TmongoDbInput-schema-not-retreiving-properly/m-p/202163#M110456

Related

Modifying data which are passed to mongoose schema

I'm passing data to a mongoose schema that look like this:
iceCreamType:{
label: "Strawberry"
value: "strawberry"
}
This data comes from a react-select component.
Now I want the data to get modified like this before sending them to the MongoDB database:
iceCreamType: "strawberry"
So I only want to send the value to MongoDB.
How can I accomplish this within the mongoose schema?
I found no good solution for this on the frontend, so I modified the data on the backend before handing it over to mongoose. Hope that helps others.

MongoDB Compass does not allow ObjectId() while populating DB with "Insert Document" feature?

I am using MongoDB Compass version 1.25.0.
I was trying to insert a document shared by one of my colleague using the "Insert Document" feature of the MongoDB Compass.
But, it's showing that the document is not in correct format.
I think it is validating JSON format and ObjectId() is not a valid JSON value.
I am aware that Compass would create ObjectId() automatically but I want to pass it explicitly.
I resorted to the Shell and I was able to insert the document.
My question is does MongoDB Compass allow entering ObjectId() from the UI?
If yes, what am I doing wrong?
I was able to insert a document with ObjectId using below syntax:
{
"_id": {
"$oid": "60261ccf416a1ed478d7357a"
}
}
I found that the documentation of a bit off in clarifying how the $oid is supposed to be used.
At least for someone beginner like me.

MongoDB Stitch returns data as $NumberDouble instead of the number itself

I'm using MongoDB Stitch to create a data enabled API, but when I make a GET request, the data is returned where numbers are displayed as:
"firstHit": {
"$numberInt": "3"
Where I would like them to be return just as:
"firstHit": 3
I have a lot of objects within objects, and I am inserting the data through the mongo shell, I'm not sure of that is of any importance.
Anyone have any experience with this? Thank you!
By default, the result format returned by MongoDB Stitch webhooks is in MongoDB Extended JSON format, or EJSON for short. This is useful to define data types that would otherwise be lost in normal JSON. There are some object types that have no equivalent in JSON, for example ObjectId() and Date().
If you would like to return as a normal JSON, you could set the response object as an example below:
exports = function(payload, response) {
result = {"firsthit": 10};
response.setStatusCode(200);
response.setHeader("Content-Type", "application/json");
response.setBody(JSON.stringify(result));
}
You may also find EJSON library and Stitch Utility Packages as useful additional information.

how to insert data on mongo db through restheart api

i am using mongo DB 3.0 version and restheart API 2.0 version. now i am trying to check my queries (URI) through postman chrome interface. and i create a database(test) table(mycol) and two documents in mongo DB, when i filter that data it shows correctly but when i try to insert data into mongodb through postman or HAL Browser it shows error, can you peoples please guide me the syntax format.
Query for filter data, it gives correct result
Query for insert a document, it shows some error
and also i need to know <docid> in the URI format : /<dbname>/<collname>/<docid>[?doc_type=TYPE] what it means <docid> please explain in detail with some example
To create a document you need either to POST the collection POST /test/mycol or PUT a document PUT /test/mycol/<docid>
<docid> stands for document id. the query parameterdocid_type is optional and allows to specify the type of the <docid> in the URL, more information in the documentation Resource URI section.
For instance, if you want to create the following document { "_id": “mydoc", “message”: “hello” } you do
PUT /test/mycol/mydoc { “message”: “hello”}
or
POST /test/mycol { "_id": “mydoc", “message”: “hello” }
In the latter case, if you don’t specify the _id, it will be autogenerated as an ObjectId.
Note that you have to specify the Content-Type request header to be either application/json or application/hal+json.
For instance, using Postman you set the body to be raw and select JSON (application/json) from the dropdown on the right. You'll notice that this will add the Content-Type header to the headers.
I run into the same problem.
The problem was I used field names starting with "_"
i.e. field names like "_type", "_name".
Try to avoid such names.
I had the same problems as you. For insert you should just write your object like this:
{
"code": 20,
"name": "s",
"family": "x"
}
And set POST your method, also for update if the document exists it will be updated, otherwise it will be created.
Please look at this link for more information
https://community.boomi.com/s/article/howtointegratewithmongodbusingopensourcerestheartlibrary#jive_content_id_Scenario_1__InsertUpdate_an_Employee_record_in_Employees_collection_using_POST

Mongoose: How to handle versioning?

Today I came to know about versioning concept in MongooseJS(here Mongoose v3 part 1 :: Versioning). But I have question here, I like the versioning feature of Mongoose, but what should I do when my schema changes ?
For example, initially my schema looks like,
{
"_id": String,
"title": String,
"description": String
}
Since I didn't know about versioning, i didn't add any versionKey option, just used the default versionKey, __v.
I created few documents with this above schema. Later I modified the schema as,
{
"_id": String,
"title": String,
"description": String,
"comments": Array
}
Here comes the problem, If I create any new document after this schema change I could able to add/push comments to the document.
But If I want to add/push comments to the document which were created with initial schema, I couldn't able to do, it throws Versioning Error: No matching document found.
Is there anyway to overcome this problem without disabling or skipping the versioning ?