Create view with two object array from seperate collections in mongodb - json

I want to create a view which fields are come from two different object array with seperate collections.For more explanation here is my code
{
"_id" : ObjectId("5e4173cf51af9f555e64531c"),
"__v" : 0,
"createdDate" : ISODate("2020-02-24T08:33:24.100Z"),
"maxDate" : {
"month" : 12,
"year" : 2018
},
"modifiedDate" : ISODate("2020-02-24T08:33:33.025Z"),
"stockArray" : [
{
"purchase_bill_date" : "1/9/2017",
"purchase_bill_series" : "A",
"purchase_bill_item_no" : "419905",
"stock_code" : "5372123-ANN",
},
{
"purchase_bill_date" : "1/9/2017",
"purchase_bill_series" : "A",
"purchase_bill_item_no" : "419905",
"stock_name" : "53743N-10-10S",
}]
}
and the other collection
{
"_id" : ObjectId("5e4173cf51af9f555e64531c"),
"__v" : 0,
"yuklenimReports" : [
{
"purchase_bill_date" : "9/3/2018",
"purchase_bill_series" : null,
"purchase_bill_item_no" : "419905",
""stock_name" : "53743N-10-10S"
}]
}
i want to inner join purchase_bill_item_no and show the others.But i couldnt handle i spent too much hour to find the solution.Thanks for all help.

Related

Firebase API REST cant filter data using orderBy [duplicate]

This question already has answers here:
How to perform sql "LIKE" operation on firebase?
(5 answers)
Closed 4 years ago.
i'm trying to filter the data that i have in a database in firebase.
I have a very simple structure of data like this.
{
"articulos" : {
"-LHYw-qz8fiTSg03TuYS" : {
"descripcion" : "refgre",
"fabricante" : "gerg",
"iva" : "21%",
"margen" : "23",
"nombre" : "greerfg",
"preciocompra" : "3213",
"preciocompraiva" : "12312",
"precioventa" : "323",
"precioventaiva" : "23",
"ref" : "4greg"
},
"-LHYwfIIoN46cjlF3VTR" : {
"descripcion" : "gdfgdfg",
"fabricante" : "dfgdf",
"iva" : "21%",
"margen" : "45",
"nombre" : "gfdgdf",
"preciocompra" : "4345",
"preciocompraiva" : "543",
"precioventa" : "543",
"precioventaiva" : "45",
"ref" : "43g34g"
},
"-LHYwvK6xAQeXHQVrmtt" : {
"descripcion" : "fdsf",
"fabricante" : "fdsf",
"iva" : "21%",
"margen" : "34",
"nombre" : "dfsfsd",
"preciocompra" : "sdfsd",
"preciocompraiva" : "dfsd",
"precioventa" : "43",
"precioventaiva" : "34",
"ref" : "432"
}
},
"clientes" : {
"-LHjGlhQD4iP9DOsGgvx" : {
"ciudad" : "rtbrtbrt",
"comentarios" : "gfdgfd",
"correo" : "brt#hotmail.com",
"cp" : "43243",
"direccion" : "tbrb",
"dni" : "rtbrtb",
"id" : 2,
"nombre" : "5brtbtrb"
},
"-LHjHImLC3UBW3M2Rf3_" : {
"ciudad" : "fmdkjsf",
"comentarios" : ".comsfdasa",
"correo" : "dkfmsldfm#jnfdjsn",
"cp" : "32434",
"direccion" : "fkdmfkjsd",
"dni" : "mklrmg",
"id" : 2,
"nombre" : "gkjsdnfgd"
}
}
}
i have been reading the documentation, and i have read about indexOn.
Currently i have this rules.
{
"rules": {
".read": true,
".write": true,
"clientes": {
".indexOn": ["nombre"]
}
}
}
I'm not sure if i'm doing it well.. but when i send de URL,
/clientes.json?orderBy="nombre"&startAt=x
it is retrieving all the "clientes" that i have in the DataBase...
How i supposed to do it for receive all the "clientes" that start at "x"... i'm trying to develop a search input in my website...
When I add your JSON to my database, it works as expected:
https://stackoverflow.firebaseio.com/51471121/clientes.json?orderBy="nombre"&startAt="x"
Gives me no results, because there is no name starting with x or later.
But:
https://stackoverflow.firebaseio.com/51471121/clientes.json?orderBy="nombre"&startAt="f"
Gives me one result, since "nombre" : "gkjsdnfgd" is after f.

Extract JSON value using Jmeter

I have this JSON:
{
"totalMemory" : 12206567424,
"totalProcessors" : 4,
"version" : "0.4.1",
"agent" : {
"reconnectRetrySec" : 5,
"agentName" : "1001",
"checkRecovery" : false,
"backPressure" : 10000,
"throttler" : 100
},
"logPath" : "/eq/equalum/eqagent-0.4.1.0-SNAPSHOT/logs",
"startTime" : 1494837249902,
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Recovery:Starting pipelines"
},
"autoStart" : false,
"recovery" : {
"agentName" : "1001",
"partitionInfo" : { },
"topicToInitialCapturePosition" : { }
},
"sources" : [ {
"dataSource" : "oracle",
"name" : "oracle_source",
"captureType" : "directOverApi",
"streams" : [ ],
"idlePollingFreqMs" : 100,
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Trying to init storage"
},
"host" : "192.168.191.5",
"metricsType" : { },
"bulkSize" : 10000,
"user" : "STACK",
"password" : "********",
"port" : 1521,
"service" : "equalum",
"heartbeatPeriodInMillis" : 1000,
"lagObjective" : 1,
"dataSource" : "oracle"
} ],
"upTime" : "157 min, 0 sec",
"build" : "0-SNAPSHOT",
"target" : {
"targetType" : "equalum",
"agentID" : 1001,
"engineServers" : "192.168.56.100:9000",
"kafkaOptions" : null,
"eventsServers" : "192.168.56.100:9999",
"jaasConfigurationPath" : null,
"securityProtocol" : "PLAINTEXT",
"stateMonitorTopic" : "_state_change",
"targetType" : "equalum",
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Recovery:Starting pipelines"
},
"serializationFormat" : "avroBinary"
}
}
I trying using Jmeter to extract out the value of agentID, how can I do that using Jmeter, what would be better ? using extractor or json extractor?
what I am trying to do is to extract agentID value in order to use it on another http request sample, but first I have to extract it from this request.
thanks!
I believe using JSON Extractor is the best way to get this agentID value, the relevant JsonPath query will be as simple as $..agentID
Demo:
See the following reference material:
JsonPath - Getting Started - for initial information regarding JsonPath language, functions, operators, etc.
JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios - for more complex scenarios.

Try to Intersect JSON Array

I need to Intersect my Query Result. After intersection the data I want to use it in my page.
This is my Data : (I store the data in variable "hasilget")
[
{
"_id" : "2017-05-22",
"kamar" : [
[
{
"_id" : ObjectId("570f5095c8dbf1045d7fe9b3"),
"namkam" : "VIP ONE",
"idtipe" : ObjectId("57023e5e36b35501f17ea5c6")
}
],
[
{
"_id" : ObjectId("570f509dc8dbf1035d7fe9b5"),
"namkam" : "VIP TWO",
"idtipe" : ObjectId("57023e5e36b37601f17ea5c6")
}
]
]
},
{
"_id" : "2017-05-23",
"kamar" : [
[
{
"_id" : ObjectId("570f5095c8dbf1045d7fe9b3"),
"namkam" : "VIP ONE",
"idtipe" : ObjectId("57023e5e36b35501f17ea5c6")
}
]
]
}
]
I have try Use "Array-Intersection" from NPM.
var inter = intersection(hasilget);
console.log("Hasil "+JSON.stringify(inter));
But The Problem is the output is Still Originally Result. The Intersection Function is not working.
Please guide me.

How to update a nested array value in mongodb?

I want update a array value that is nested within an array value: i.e. set
status = enabled
where alerts.id = 2
{
"_id" : ObjectId("5496a8ed49847b6cd7c7b350"),
"name" : "joe",
"locations" : [
{
"name": "my location",
"alerts" : [
{
"id" : 1,
"status" : null
},
{
"id" : 2,
"status" : null
}
]
}
]
}
I would have used the position $ character, but cannot use it twice in a statement - multi positional operators are not supported yet: https://jira.mongodb.org/browse/SERVER-831
How do I issue a statement to only update the status field of an alert matching an id of 2?
UPDATE
If I change the schema as follows:
{
"_id" : ObjectId("5496ab2149847b6cd7c7b352"),
"name" : "joe",
"locations" : {
"my location" : {
"alerts" : [
{
"id" : 1,
"status" : "enabled"
},
{
"id" : 2,
"status" : "enabled"
}
]
},
"my other location" : {
"alerts" : [
{
"id" : 3,
"status" : null
},
{
"id" : 4,
"status" : null
}
]
}
}
}
I can then use:
update({"locations.my location.alerts.id":1},{$set: {"locations.my location.alerts.$.status": "enabled"}});
Problem is I cannot create indexes on the alert id :-(
it may be better of modelled as such, specially if an index on location and,or alerts.id is needed.
{
"_id" : ObjectId("5496a8ed49847b6cd7c7b350"),
"name" : "joe",
"location" : "myLocation",
"alerts" : [{
"id" : 1,
"status" : null
},
{
"id" : 2,
"status" : null
}
]
}
{
"_id" : ObjectId("5496a8ed49847b6cd7c7b350"),
"name" : "joe",
"location" : "otherLocation",
"alerts" : [{
"id" : 1,
"status" : null
},
{
"id" : 2,
"status" : null
}
]
}
I think you are having a wrong tool for the job. What you have in your example is relational data and it's much easier to handle with relational database. So I would suggest to use SQL-database instead of mongo.
But if you really want to do it with mongo, then I guess the only option is to fetch the document and modify it and put it back.

AngularJS Display value

I have in my .html:
{{data}}
It will display:
[ { "images" : [ { "__v" : 0,
"_id" : "542e57a709d2d60000c93953",
"name" : "image1",
"url" : "http://www.syll.com"
},
{ "__v" : 0,
"_id" : "543249050fcae2f082ca3e70",
"name" : "imageOCR1",
"url_image" : "http://meta-e.aib.uni-linz.ac.at/ocr.gif"
},
{ "__v" : 0,
"_id" : "543249050fcae2f082ca3e71",
"name" : "imageOCR2",
"url_image" : "http://www.textcreationpartnership.org/xxx.jpg"
}
],
"itemCount" : 70,
"pageCount" : 7
} ]
But I would like to display the value in "pageCount" so 7.
How I can do that without ng-repeat?
btw, y controller works fine.
I tried:
{{data.pageCount}}
But it doesn't work.
Thanks!
[EDIT] changed with the righ JSON and formatted.
It looks like your data is all contained within a single-element array. Have you tried the following?
{{data[0].pageCount}}