How to query a Document by ObjectId with rmongodb - r

Here is what you get in mongo shell :
db.col.find(ObjectId("5571849db1969e0a6eb32731")).pretty()
{
"_id" : ObjectId("5571849db1969e0a6eb32731"),
"name" : "Some name",
"logo" : "Some logo",
"users" : [
ObjectId("5571830031c7fc341bc2e105"),
ObjectId("5571830031c7fc341bc2e107")
],
"admins" : [ ],
"__v" : 0,
"steps" : 5782
}
Here is what I get in rmongo :
myResult <- mongo.find(Connexion, "db.col", query='ObjectId("5571849db1969e0a6eb32731")')
#Error in mongo.bson.from.JSON(arg) :
# Not a valid JSON content: ObjectId("5571849db1969e0a6eb32731")
So, how to do it right ?
Just in case : I had a look at this already. But mongolite doesn't support authentication (which is therefore a no-go) and I don't understand what to do with the second answer. If I try
result <- mongo.find(Connexion, "db.col", query=mongo.oid.from.string("5571849db1969e0a6eb32731"))
I get
# Error in mongo.bson.from.argument(query) : Can't convert to bson: argument should be one of 'list', 'mongo.bson' or 'character'(valid JSON)

This should work:
result <- mongo.find(Connexion, "db.col", query=list('_id' = mongo.oid.from.string("5571849db1969e0a6eb32731")))

Related

How to fetch SHA_256 value from manifest.json file in JFROG

I am trying to fetch the SHA_256 value from manifest.json file but unable to get using aql.
Below is the cmd I am using:
ubuntu#test:~$ **curl -sS -u sumkumar:$pw -XPOST -k -H "Content-type: text/plain" https://<URL>/artifactory/api/search/aql -d 'items.find({"repo":"xyz"},{"path":"a/b/c"}).include("*")'**
{
"results" : [ {
"repo" : "xyz",
"path" : "a/b/c",
"name" : "manifest.json",
"type" : "file",
"size" : 1579,
"created" : "2018-03-13T11:58:33.771Z",
"created_by" : "uex-sp-cd",
"modified" : "2018-03-15T14:17:38.299Z",
"modified_by" : "uex-sp-cd",
"updated" : "2018-03-15T14:17:38.299Z",
"depth" : 4,
"actual_md5" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"actual_sha1" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"original_md5" : "NO_ORIG",
"original_sha1" : "NO_ORIG",
"virtual_repos" : [ ]
},{
However, if you look the original manifest.json file from UI.It contains SHA256 value.
enter image description here
According to the AQL documentation, the item entity has the sha256 field. But it mentions the following note:
SHA-256 is supported from Artifactory version 5.5
You can only do an AQL search on an Artifact that has been deployed to Artifactory version 5.5 or above, or if you have migrated your database as described in SHA-256 Support after upgrading Artifactory to version 5.5 and above.
Please verify your Artifactory fits the requirements above.
In addition, assuming this is a Docker manifest.json, it specifically should also have the SHA256 in a property named docker.manifest.digest (and maybe also a property named sha256). To get the property values you can add "property.*" to the include(..) part of the query.
For example:
items.find({"repo":"xyz","path":"a/b/c","name":"manifest.json"})
.include("repo","path","name","sha256","property.*")
Will return something like:
{
"results" : [ {
"repo" : "xyz",
"path" : "a/b/c",
"name" : "manifest.json",
"sha256" : "34cb6f8e1e1aca...",
"properties" : [ {
"key" : "docker.manifest.digest",
"value" : "sha256:34cb6f8e1e1aca..."
},{
"key" : "sha256",
"value" : "34cb6f8e1e1aca..."
}
...

Dynamodb stream kinesis - Incomplete hash range found between

I have kinesis stream from DynamoDB. And I am processing it through aws KCL sdk v1.14.0. I see below occasional errors in the logs. I also observe that startingHashKey is always 1 and endingHashKey is 0 for all shards in the dynamodb lease table. Any clue why is this happening?
Incomplete hash range found between {
"leaseKey" : "shardId-00000001601992582645-697387df",
"leaseOwner" : "eu01-stg01-vendor-service-74b4cd66b6-6hcfb:29dafc2f-c87f-4c70-b210-d38db7ebfc87",
"leaseCounter" : 4080,
"concurrencyToken" : null,
"lastCounterIncrementNanos" : null,
"checkpoint" : {
"sequenceNumber" : "47515300000000010794885359",
"subSequenceNumber" : 0,
"shardEnd" : false
},
"pendingCheckpoint" : null,
"ownerSwitchesSinceCheckpoint" : 0,
"parentShardIds" : [ ],
"childShardIds" : [ ],
"hashKeyRange" : {
"startingHashKey" : 0,
"endingHashKey" : 1
}
} and {
"leaseKey" : "shardId-00000001602005637902-6358a08a",
"leaseOwner" : "eu01-stg01-vendor-service-74b4cd66b6-6hcfb:29dafc2f-c87f-4c70-b210-d38db7ebfc87",
"leaseCounter" : 397,
"concurrencyToken" : null,
"lastCounterIncrementNanos" : null,
"checkpoint" : {
"sequenceNumber" : "TRIM_HORIZON",
"subSequenceNumber" : 0,
"shardEnd" : false
},
"pendingCheckpoint" : null,
"ownerSwitchesSinceCheckpoint" : 0,
"parentShardIds" : [ "shardId-00000001601992582736-2c3fc0ff" ],
"childShardIds" : [ ],
"hashKeyRange" : {
"startingHashKey" : 0,
"endingHashKey" : 1
}
}
I also get this error, but the stream seems to work properly. (I am using it to monitor the data change).
Then I dig the source code of this error log, find the part code is added on Jun 22, 2020,
This is the source code: https://github.com/awslabs/amazon-kinesis-client/blob/6fbfc21ad7d6a2722491806a411d168304167f7f/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/PeriodicShardSyncManager.java#L298
This is the blame: https://github.com/awslabs/amazon-kinesis-client/blame/6fbfc21ad7d6a2722491806a411d168304167f7f/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/PeriodicShardSyncManager.java#L298
This is the commit: https://github.com/awslabs/amazon-kinesis-client/commit/3a88a60a4ee7bb8f969b36cb79e7665a7395b6ec
it is only in the latest version: 1.14.0
So I go back one version to use 1.13.3 then no this error.
I have submitted an issue on the GitHub to see what the reason for the error. https://github.com/awslabs/amazon-kinesis-client/issues/758

Projection from Mongo API C# driver not supported while querying DocumentDB

I am using following code (MongoDB C# driver) to projects fields ,
where queryDocument = '{{ "FullName" : /myname/i }}'
BsonDocument projectionDefination = Builders.Projection.ToBsonDocument();
projectionDefination.Add(new BsonElement("FullName", "myname"));
collection.Find(queryDocument).Project(projectionDefination);
getting following error:
{"Command failed."}
{{ "_t" : "OKMongoResponse", "ok" : 0, "code" : 9, "errmsg" : "Syntax error, incorrect syntax near '9'.", "$err" : "Syntax error, incorrect syntax near '9'." }}
Can anyone update on this?
I also tried above with RoboMongo
Command: db.getCollection('Employee').find({ "FullName": /User/i}).projection({ "FullName" : "$FullName" })
Received following error:
Error: error: {
"_t" : "OKMongoResponse",
"ok" : 0,
"code" : 9,
"errmsg" : "Syntax error, incorrect syntax near '15'.",
"$err" : "Syntax error, incorrect syntax near '15'."
}
According to your description, I checked this issue and I could encounter the same issue:
As mongoDB document states about Projection in db.collection.find():
The projection parameter determines which fields are returned in the matching documents. The projection parameter takes a document of the following form:
{ field1: <value>, field2: <value> ... }
The <value> can be any of the following:
1 or true to include the field in the return documents.
0 or false to exclude the field.

Want to get the data from a nested mongodb from R shiny app

My mongodb is looking like this :
"_id" : ObjectId("5751749723be8328848af30e"),
"mem_id" : 1.0,
"mem_name" : "Member1",
"home" : "8001234567",
"mobile" : "8771231234",
"email" : "jd#example.com",
"mem_create_date" : ISODate("2016-06-03T12:14:15.642Z"),
"paymethod" : {
"pm_id" : "99991",
"pm_name" : "FA11",
"pm_create_Date" : ISODate("2013-12-09T21:05:00.000Z"),
"routing_no" : "075000051"
},
"payee" : {
"pae_id" : "88881",
"pae_name" : "Payee1",
"home" : "800-123-45671",
"mobile" : "877-123-12341",
"email" : "jd#example.com",
"act_no" : "0213654781",
"pae_create_date" : ISODate("2013-12-09T21:05:00.000Z"),
"payment" : {
"pmt_id" : "66661",
"pmt_amt" : "71",
"pmt_create_date" : ISODate("2013-12-09T21:05:00.000Z"),
"pmt_type" : "check"
}
}
}
I need to get these values with the help of mongolite and show them in a plot/graph with R shiny web app.
I could not find any example with nested mongodb on net. And whenever i am trying to read the data i am getting the below err :
error in if (inherits(x j dataframe ) && ncol(xj) 1l) x j - as.matrix(x j )
Can anyone please help/guide me here. I am a java developer but i am new to R language.
Thanks.

nvd3 not displaying graph for data with value of 1000 or higher

I am tring to set up analytics for email campaigns with a discrete bar graph and I just found out that nvd3 has a weird bug where any data point with a value of 1000 or higher doesnt get rendered right.
here is the jsfiddle
http://jsfiddle.net/aMnSb/
var data = [{
key: "Cumulative Return",
values: [
{"label" : "delivered","value" : "999","color" : "458ec1",},{"label" : "opened","value" : "176","color" : "65a1cb",},{"label" : "clicked","value" : "8","color" : "7fb1d4",},{"label" : "unopened","value" : "487","color" : "aacce3",},{"label" : "bounced","value" : "357","color" : "eec4cc",},{"label" : "unsubscribed","value" : "1","color" : "e39ba9",}, ]
}];
works , but this doesnt work
var data_large = [{
key: "Cumulative Return",
values: [
{"label" : "delivered","value" : "1000","color" : "458ec1",},{"label" : "opened","value" : "176","color" : "65a1cb",},{"label" : "clicked","value" : "8","color" : "7fb1d4",},{"label" : "unopened","value" : "487","color" : "aacce3",},{"label" : "bounced","value" : "357","color" : "eec4cc",},{"label" : "unsubscribed","value" : "1","color" : "e39ba9",}, ]
}];
You're seeing this behaviour because the numbers in your JSON aren't actually numbers, but strings (enclosed in quotes). It works if you remove the quotes around the numbers in the JSON.

Resources