How to write graphql schema with below requirement - kotlin

Hi I just started with the graphql and need to build some logic in kotlin. But I need to write some schema first for below requirement. can you please someone help me
Input: (org_id)
Output: (TotalCount, V1Count, V2Count)
V1Count: (BasicCount, CoreCount, FullCount)
V2Count: (BasicCount, CoreCount, FullCount)
{
“total_count”: 1234,
“v1_count”: {
“basic_users”: 1234,
“core_users”: 2345,
“full_users”: 5656,
},
“v2_count”: {
“basic_users”: 1234,
“core_users”: 2345,
“full_users”: 5656
}
}

Related

How to use Aggregate in AppSmith

In my database of MongoDB, I can't insert new register in the historial
I want insert the phone and start date
My model in Mongo is this
And the code what write is this
{
"aggregate": "dids",
"pipeline": [
{
"$match": {
"_id": ObjectId({{sPhone.selectedOptionValue}})
}
}
],
"cursor": {
"batchSize": 10
}
}
how insert $addFields in pipeline segment?
"$addFields": {
"history.contract_id": {{tableOfContracts.selectedRow._id}},
"history.start_date": {{dtpkStart.selectedDate}}
}
Yes is written below the match segment, throws error ('A pipeline stage specification object must contain exactly one field')
Any solution?
To insert data, you can consult it in the appsmith documentation in the following links.
Link to the explanation of mongodb methods: https://www.mongodb.com/docs/manual/reference/insert-methods/
Link to query syntax: https://docs.appsmith.com/reference/datasources/querying-mongodb/mongo-syntax
Query configuration:enter image description here

Can I refer to the Row/Document internal variables when filtering in Prisma?

How can I use row/document variables in filters and sorting?
As you know in SQL we can filter on joins beside the foreign key Something like this
Select * From A LEFT JOIN B on A.key = B.foriegnKey AND B.key IN A.currentSelection
or even in mongo lookup
collection('A').aggregate([{
$lookup: {
from: "B",
localField: "key",
foreignField: "foreignKey",
let: { A_currentSelection: "$currentSelection" },
pipeline: [{
$match: {
$expr: { $in: ["$key", "$$A_currentSelection"] }
}
}],
as: "matches"
}
},
])
But you can't do the following in Prisma
prisma.A.findMany({
include: {
B: {
where: {
'$A.currentSelection': {
has: "$B.key"
}
}
}
}
})
Regardless of the query itself, the idea is that I can access the current row/document variables in the query, I also know that I can modify the structure of the database to get around these kinds of issues but the database is already structured in a specific manner that might break some parts of the code and it's also not viable to change the structure just because Prisma is not lacking in this part.
At first, I was using a raw query to get around this and know I've created more complex relationships in the schema to fix this in Prisma in this case, but if anyone knows a more elegant solution then I'd be grateful

AWS mqtt SQL query

I have the following mqtt message:
{
"sensors": [
{
"lsid": 412618,
"data": [
{
"temp_in": 72.3,
"heat_index_in": 72,
"dew_point_in": 55.9,
"ts": 1652785241,
"hum_in": 56.3
}
],
"sensor_type": 243,
"data_structure_type": 12
},
{
"lsid": 421195,
}
I can get the "sensors,0.lsid" value and the entire "data" array using this query:
select get(sensors,0).lsid as ls, get(sensors, 0).data as data1 from "topic"
but what I really need is to get "temp_in:72.3" , i.e. the values from the second level array
I've tried using this :AWS Doc., but unless I'm not following it correctly, it doesn't seem to work.
Any help would be greatly appreciated

Get values from JSON using JSON_VALUE in SQL Server

I have the below JSON (Sorry I dont know how to format it!) and I am struggling to understand how to extract values at the different levels.
My code so far is this which brings back the data required from the first few columns..
,JSON_VALUE(jsonstring,'$[0].addPoint') Addpoint
,JSON_VALUE(jsonstring,'$[0].department') department
,JSON_VALUE(jsonstring,'$[0].subBuilding') subBuilding
,JSON_VALUE(jsonstring,'$[0].buildingNumber') Buildingnumber
,JSON_VALUE(jsonstring,'$[0].buildingGroup') buildingGroup
However I am not sure how I would get the below columns..
"mpan"
"serialnumber"
Can someone advise me as to what I am missing here? I haven't worked with JSON before and have googled but can't find a definite solution
[
{
"addPoint":null,
"department":null,
"subBuilding":null,
"buildingNumber":"1",
"buildingName":null,
"buildingGroup":null,
"poBox":null,
"subStreet":"The Arches",
"subLocality":null,
"stateRegion":"Lancashire",
"subAdministrativeArea":null,
"administrativeArea":null,
"superAdministrativeArea":null,
"countryCode":"GBR",
"countryName":null,
"dpsZipPlus":"1B5",
"formattedAddress":"TEST,,MANC,Lancashire,66666",
"welshSubStreet":null,
"welshStreet":null,
"welshSubLocality":null,
"welshLocality":null,
"welshTown":null,
"geographicInformation":null,
"additionalItems":{
"item":[
{
"key":"DATASOURCE",
"value":"tu_REGISTER"
}
],
"tmp":null
},
"groupedAdditionalItems":null,
"persons":null,
"uprn":null,
"lpi":null,
"blpu":null,
"streetDescriptor":null,
"streetInformation":null,
"companyInformation":null,
"dnbCompanyInformation":null,
"onsPointerInformation":null,
"classification":null,
"osAl2Toid":null,
"osItnToid":null,
"osTopoToid":null,
"voaCtRecord":null,
"voaNdrRecord":null,
"apOSAPR":null,
"rmUDPRN":"2744498",
"mrOccCountSpecified":false,
"alias":null,
"utilitiesInformation":{
"fuelType":1,
"fuelTypeSpecified":true,
"gasInformation":null,
"electricityInformation":{
"meterPoint":[
{
"mpan":"162558070",
"meter":[
{
"serialNumber":"D07W05001",
"type":"N"
}
],
"profileType":"02",
"timeSwitchCode":"811",
"lineLossFactorId":"531",
"standardSettlementConfiguration":"0151",
"energisationStatus":"E",
"energisationEffectiveFromDate":{
"day":5,
"daySpecified":true,
"month":12,
"monthSpecified":true,
"year":2014,
"yearSpecified":true
},
"distributorId":"16",
"gspid":"_G"
}
],
"tmp":null
},
"tmp":null
},
"organisation":null,
"street":"Clive Street",
"town":"MANCH",
"postCode":"r4d 1ES",
"locality":null
}]
You can use the following paths:
$[0].utilitiesInformation.electricityInformation.meterPoint[0].mpan
$[0].utilitiesInformation.electricityInformation.meterPoint[0].meter[0].serialNumber

Get data on basis of fields in Yii2

I am trying to get data on basis of fields in query param ie
users/1?fields=id,name
its give id and name using findOne
User::findOne(1);
Result:
{
"id": 12,
"name": 'Jhon'
}
When
users?fields=id,name
Its give all fields of user Model using findAll()
User::findAll([$ids])
Result:
[
{
'id': 1
'name': abc
'age':30
'dob':1970
'email':abc#test.com
},
{
'id': 2
'name': abc
'age':30
'dob':1970
'email':abc1#test.com
},
Why findAll() not work like findOne() result
I have read Data provider and solve the problem