Requirement- from below code snippet, i need to pull data related to market segment= unicare.
in the subsequent request need to pass both state and market segment unicare..
first i need to find do i see unicare market segement.. if Yes what is the first occurance and its associated state. to be captured and placed in the consequent request.
tried lr_json_get_values. can you please help on this.
{
"taxID": "23424",
"firstName": "afsafa",
"lastName": "asdfsfa",
"middleName": "adfasad",
"npn": "324322424",
"stateResident": "WI",
"dateBirth": "234324224",
"licenseDetails": [
{
"state": "CO",
"license": [
{
"licenseNum": "3234224",
"dateUpdated": "12/08/2020",
"dateIssueLicenseOrg": "324242",
"dateExpireLicense": "243242",
"licenseClass": "avadfa Producer",
"licenseClassCode": "2",
"residencyStatus": "444",
"active": "Yes",
"details": [
{
"loa": "aafafafa",
"loaCode": "44444",
"authorityIssueDate": "44345353",
"status": "Active",
"statusReasonDate": "444444",
"ceCompliance": "N/S",
"ceCreditsNeeded": "0"
}
]
}
],
"address": [
{
"dateUpdated": "423333",
"addressTypeCode": "2",
"addrType": "adfafa",
"addrLine1": "asssss",
"nameCity": "aaaa",
"nameState": "WI",
"zip": "4444444",
"country": "U.S.A."
},
{
"dateUpdated": "10/22/2020",
"addressTypeCode": "2",
"addrType": "adfafa",
"addrLine1": "Fhk sfsfsafs",
"addrLine2": "6sdfsfsfa Ave",
"nameCity": "dfsafa",
"nameState": "WI",
"zip": "sdfsaff",
"country": "U.S.A."
},
{
"dateUpdated": "45353",
"addressTypeCode": "1",
"addrType": "45adfa",
"addrLine1": "1sfsafaf",
"nameCity": "adfafafa",
"nameState": "WI",
"zip": "34444-434",
"country": "U.S.A."
}
],
"brands": [
"ALWAYS"
],
"marketSegment": [
{
"brandName": "ALWAYS",
"lobTypes": [
"Individual",
"Senior"
]
},
{
"brandName": "Unicare",
"lobTypes": [
"Individual",
"Senior",
"Small Group",
"Large Group"
]
}
],
"isLifeExists": false
},
{
"state": "FL",
"license": [
{
"licenseNum": "3234224",
"dateUpdated": "12/08/2020",
"dateIssueLicenseOrg": "324242",
"dateExpireLicense": "243242",
"licenseClass": "avadfa Producer",
"licenseClassCode": "2",
"residencyStatus": "444",
"active": "Yes",
"details": [
{
"loa": "aafafafa",
"loaCode": "44444",
"authorityIssueDate": "44345353",
"status": "Active",
"statusReasonDate": "444444",
"ceCompliance": "N/S",
"ceCreditsNeeded": "0"
}
]
}
],
"address": [
{
"dateUpdated": "423333",
"addressTypeCode": "2",
"addrType": "adfafa",
"addrLine1": "asssss",
"nameCity": "aaaa",
"nameState": "WI",
"zip": "4444444",
"country": "U.S.A."
},
{
"dateUpdated": "10/22/2020",
"addressTypeCode": "2",
"addrType": "adfafa",
"addrLine1": "Fhk sfsfsafs",
"addrLine2": "6sdfsfsfa Ave",
"nameCity": "dfsafa",
"nameState": "WI",
"zip": "sdfsaff",
"country": "U.S.A."
},
{
"dateUpdated": "45353",
"addressTypeCode": "1",
"addrType": "45adfa",
"addrLine1": "1sfsafaf",
"nameCity": "adfafafa",
"nameState": "WI",
"zip": "34444-434",
"country": "U.S.A."
}
],
"brands": [],
"marketSegment": [
{
"brandName": "Unicare",
"lobTypes": [
"Individual",
"Senior",
"Small Group",
"Large Group"
]
}
],
"isLifeExists": false
},
{
"state": "WI",
"license": [
{
"licenseNum": "3234224",
"dateUpdated": "12/08/2020",
"dateIssueLicenseOrg": "324242",
"dateExpireLicense": "243242",
"licenseClass": "avadfa Producer",
"licenseClassCode": "2",
"residencyStatus": "444",
"active": "Yes",
"details": [
{
"loa": "aafafafa",
"loaCode": "44444",
"authorityIssueDate": "44345353",
"status": "Active",
"statusReasonDate": "444444",
"ceCompliance": "N/S",
"ceCreditsNeeded": "0"
}
]
}
],
"address": [
{
"dateUpdated": "423333",
"addressTypeCode": "2",
"addrType": "adfafa",
"addrLine1": "asssss",
"nameCity": "aaaa",
"nameState": "WI",
"zip": "4444444",
"country": "U.S.A."
},
{
"dateUpdated": "10/22/2020",
"addressTypeCode": "2",
"addrType": "adfafa",
"addrLine1": "Fhk sfsfsafs",
"addrLine2": "6sdfsfsfa Ave",
"nameCity": "dfsafa",
"nameState": "WI",
"zip": "sdfsaff",
"country": "U.S.A."
},
{
"dateUpdated": "45353",
"addressTypeCode": "1",
"addrType": "45adfa",
"addrLine1": "1sfsafaf",
"nameCity": "adfafafa",
"nameState": "WI",
"zip": "34444-434",
"country": "U.S.A."
}
],
"brands": [
"ALWAYS",
"WCICWCICsd(sdfsafasdfsa COLLABORATIVE sdfsfsdf COMP)"
],
"marketSegment": [
{
"brandName": "ALWAYS",
"lobTypes": [
"Individual",
"Senior",
"Small Group",
"Large Group"
]
},
{
"brandName": "WCICsd(sdfsafasdfsa COLLABORATIVE sdfsfsdf COMP)",
"lobTypes": [
"Individual",
"Small Group",
"Large Group"
]
},
{
"brandName": "Unicare",
"lobTypes": [
"Individual",
"Senior",
"Small Group",
"Large Group"
]
}
],
"isLifeExists": true
}
]
}
Related
I'm struggling to remove key 'customerNumber' from sub-arrays allAddresses and allPersons. my requirement is that in the below payload key customerNumber should only appear in the parent array CustomerMaster. all other appearances of customerNumber should be deleted.
with the below code I get error groovy.lang.MissingPropertyException: No such property: allAddresses for class: java.util.LinkedHashMap$Entry. To my surprise the code works when the key CustomerMaster is an array. I dont understand why it fails if the customer is not an array
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.JsonSlurper;
import groovy.json.JsonOutput;
import groovy.json.*
def Message removeCustomerNumber(Message message) {
def body = message.getBody(String)
//def body = message.getBody(String.class);
body=body.toString();
def json = new JsonSlurper().parseText(body)
json.CustomerMaster.each{
// if (it.allAddresses.metaClass.respondsTo('each')){
// if(it.metaClass.hasProperty(it, 'allAddresses')){
it.allAddresses.each{
it.remove('customerNumber')
}
// }
// }
}
def out= JsonOutput.toJson(json);
//out = JsonOutput.prettyPrint()
message.setBody(out);
return message;
}
in other words when the CustomerMaster is an collection, I have no issue. I tried checking with hasProperty() and respondsTo() with out success
payload:
{
"CustomerMaster": {
"activitySector": "01",
"cognosCode": "ES001",
"companyName1": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"companyName2": "ALIAXIS IBERIA S.A.U.",
"creditControlArea": "ES01",
"currency": "EUR",
"customerNumber": "0000100001",
"allPersons": [
{
"birthday": "00000000",
"cognosCode": "ES001",
"contactId": "0000000308",
"customerNumber": "0000100001",
"jobTitle": "ENCARGADO COBROS",
"language": "ES",
"lastName": "EDUARDO JIMENEZ"
},
{
"birthday": "20210419",
"cognosCode": "ES001",
"contactId": "0000000475",
"customerNumber": "0000100001",
"email1": "FACTURASPDF.SNPT#ABAST.ES",
"jobTitle": "ENVÍO FACTURACIÓN",
"language": "ES",
"lastName": "FACTURACION"
},
{
"birthday": "00000000",
"cognosCode": "ES001",
"contactId": "0000000036",
"customerNumber": "0000100001",
"jobTitle": "REPRESENTANTE LEGAL",
"language": "ES",
"lastName": "D. JULIO ESTEBAN SALGADO"
}
],
"allAddresses": [
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "WE"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "AG"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "RE"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "RG"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "ZV"
}
],
"email1": "JUANJOSE.GONZALEZ#SANIPLAST.ES",
"entityCode": "ES01",
"fax": "985793802",
"phone1": "985-792224",
"phone2": "985791154ISABEL",
"termsofPayment": "Z037"
}
}
def json = new JsonSlurper().parseText(body)
if(json.CustomerMaster instanceof List){
json.CustomerMaster.each{
it.allPersons?.each{it.remove("customerNumber")}
it.allAddresses?.each{it.remove("customerNumber")}
}
}else{
json.CustomerMaster?.allPersons?.each{it.remove("customerNumber")}
json.CustomerMaster?.allAddresses?.each{it.remove("customerNumber")}
}
with ternary operator
( json.CustomerMaster instanceof List ? json.CustomerMaster : [json.CustomerMaster] ).each{
it?.allPersons?.each{it.remove("customerNumber")}
it?.allAddresses?.each{it.remove("customerNumber")}
}
My documents look like this
{
"_id": {
"$oid": "62825f71005ce00c5f0235c1"
},
"user": "jon",
"roles": {
"User": 2001,
},
"STOCK ": [
{
"sku": "BLACK-M",
"productname": "BLACK",
"sendout": 0,
"recived": 1,
"totalinstock": 40,
"location": "B32",
"_id": {
"$oid": "62826016005ce00c5f0235c8"
}
},
{
"sku": "CJNS",
"productname": "89796363",
"sendout": 0,
"recived": 45,
"totalinstock": 0,
"location": "B232",
"_id": {
"$oid": "62836f2d56b4f1ac79c99b8d"
}
}
],
"ORDERS": [
{
"date": {
"$date": "2022-06-02T15:23:58Z"
},
"OrderNumber": "745607",
"City": "xxxxx",
"Address": "yyyyyy",
"Phone": "8678678678",
"Name": "Holly ",
"Trackingnumber": 40,
"ZipCode": 00000,
"Province": "New ",
"Quantity": [
1
],
"Product_Name": [
" pants pants"
],
"SKU": [
"CJNS"
],
"_id": {
"$oid": "6298d61ba6eeec72b78332a7"
}
},
{
"date": {
"$date": "2022-06-02T15:23:58Z"
},
"OrderNumber": "748840",
"City": "xxxxx",
"Address": "yyyyyy",
"Phone": "354353454",
"Name": "Michael",
"Trackingnumber": 0,
"ZipCode": 00000,
"Province": "North",
"Quantity": [
1
],
"Product_Name": [
" pants pants"
],
"SKU": [
"CJNS"
],
"_id": {
"$oid": "6298d61ba6eeec72b78332a9"
}
}
]
}
I successful to return all the objects in STOCK or all the objects in ORDERS
Through this query
const foundUser= await User.find({"user":req.body.user},("Orders") ).exec()
Now I want to filter the response to include only items where "Trackingnumber" is different from 0
For the sample data I expect to receive only
{
"date": {
"$date": "2022-06-02T15:23:58Z"
},
"OrderNumber": "748840",
"City": "xxxxx",
"Address": "yyyyyy",
"Phone": "354353454",
"Name": "Michael",
"Trackingnumber": 0,
"ZipCode": 00000,
"Province": "North",
"Quantity": [
1
],
"Product_Name": [
" pants pants"
],
"SKU": [
"CJNS"
],
"_id": {
"$oid": "6298d61ba6eeec72b78332a9"
}
}
You can use an aggregation pipeline with a $filter for this:
db.collection.aggregate([
{
$match: {
"user": "jon"
}
},
{
$project: {
ORDERS: {
$filter: {
input: "$ORDERS",
as: "item",
cond: {$ne: ["$$item.Trackingnumber", 0]}
}
}
}
}
])
Playground example
User.find({"Orders" : {"Trackingnumber": 0} })
Tested on Shopware 6.3.5.1:
I'm trying to create a product via API together with its parent. That is necessary, because I can only iterate over variants in the other system.
As far as I can tell there's no conflict with the IDs or duplicates. Neither the product nor its parent already exist.
But when I do this:
POST https://somedomain.de/api/v3/_action/sync
Content-Type: application/json
Accept: application/json
Authorization: Bearer {{auth_token}}
{
"7508d64f832fb06b8f82f78963b280ab": {
"action": "upsert",
"entity": "product",
"payload": [
{
"id": "7508d64f832fb06b8f82f78963b280ab",
"__code": "1111111189",
"stock": 99,
"taxId": "d390c2f211144543845dbf76fa69d17a",
"cmsPageId": null,
"deliveryTimeId": null,
"manufacturerId": null,
"visibilities": [
{
"id": "e24f994426246015347bba784ac69a97",
"productId": "7508d64f832fb06b8f82f78963b280ab",
"salesChannelId": "8e7c11e2540b4c71b521d5a59920e142",
"visibility": 30
}
],
"unitId": null,
"price": [
{
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net": 25,
"gross": 29.75,
"linked": true
}
],
"productNumber": "1111111189",
"coverId": null,
"translations": {
"ce1df85b5f1c4eedbc532cbd34c57df6": {
"name": "Converse black",
"description": "Converse black"
},
"2fbb5fe2e29a4d70aa5854ce7ce3e20b": {
"name": "Converse black",
"description": "Converse black"
}
},
"categories": [
{
"id": "e90cf50735a0d6f69b2dbf599caa4954"
},
{
"id": "a5b4753f41c8f4bedba1bf5954c961cb"
}
],
"properties": [
{
"id": "a01a0380ca3c61428c26a231f0e49a09"
}
],
"media": [
{
"id": "cb9a886400616c215a588b13cb7c662b",
"mediaId": "a7aabb5ff4dc3c99ba45724ec7477ffe"
}
],
"parent": {
"id": "7a788255eab96bf51002829b3a6becf2",
"__code": "1111111189",
"stock": 99,
"taxId": "d390c2f211144543845dbf76fa69d17a",
"cmsPageId": null,
"deliveryTimeId": null,
"manufacturerId": null,
"visibilities": [
{
"id": "8d5a7e2b2c02986a924eaf3d9504413c",
"productId": "7a788255eab96bf51002829b3a6becf2",
"salesChannelId": "8e7c11e2540b4c71b521d5a59920e142",
"visibility": 30
}
],
"unitId": null,
"price": [
{
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net": 25,
"gross": 29.75,
"linked": true
}
],
"productNumber": "converseblack",
"coverId": null,
"translations": {
"ce1df85b5f1c4eedbc532cbd34c57df6": {
"name": "Converse black",
"description": "Converse black"
},
"2fbb5fe2e29a4d70aa5854ce7ce3e20b": {
"name": "Converse black",
"description": "Converse black"
}
},
"categories": [
{
"id": "e90cf50735a0d6f69b2dbf599caa4954"
},
{
"id": "a5b4753f41c8f4bedba1bf5954c961cb"
}
],
"properties": [
{
"id": "a01a0380ca3c61428c26a231f0e49a09"
}
],
"media": [
{
"id": "cb9a886400616c215a588b13cb7c662b",
"mediaId": "a7aabb5ff4dc3c99ba45724ec7477ffe"
}
],
"configuratorSettings": [
{
"optionId": "a01a0380ca3c61428c26a231f0e49a09",
"id": "db3787abb8d6372e1997c144031ef1e2"
}
]
},
"parentId": "7a788255eab96bf51002829b3a6becf2",
"options": [
{
"id": "a01a0380ca3c61428c26a231f0e49a09"
}
]
}
]
}
}
I get as a response that the integrity constraint productId X saleschannelId in visibilities gets violated:
{
"success": false,
"data": {
"7508d64f832fb06b8f82f78963b280ab": {
"result": [
{
"entities": [],
"errors": [
{
"code": "0",
"status": "500",
"title": "Internal Server Error",
"detail": "An exception occurred while executing 'INSERT INTO `product_visibility` (`id`, `product_id`, `product_version_id`, `sales_channel_id`, `visibility`, `created_at`) VALUES (?, ?, ?, ?, ?, ?)' with params [\"\\x8d\\x5a\\x7e\\x2b\\x2c\\x02\\x98\\x6a\\x92\\x4e\\xaf\\x3d\\x95\\x04\\x41\\x3c\", \"\\x7a\\x78\\x82\\x55\\xea\\xb9\\x6b\\xf5\\x10\\x02\\x82\\x9b\\x3a\\x6b\\xec\\xf2\", \"\\x0f\\xa9\\x1c\\xe3\\xe9\\x6a\\x4b\\xc2\\xbe\\x4b\\xd9\\xce\\x75\\x2c\\x34\\x25\", \"\\x8e\\x7c\\x11\\xe2\\x54\\x0b\\x4c\\x71\\xb5\\x21\\xd5\\xa5\\x99\\x20\\xe1\\x42\", 30, \"2021-02-22 11:36:18.099\"]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'zx\\x82U\\xEA\\xB9k\\xF5\\x10\\x02\\x82\\x9B:k\\xEC\\xF2-\\x0F\\xA9\\x1C\\x...' for key 'uniq.product_id__sales_channel_id'"
}
]
}
],
"extensions": []
}
},
"extensions": []
}
I just figured out, that it's possible to extract the nested entities into separate actions (that works):
{
"7508d64f832fb06b8f82f78963b280ab": {
"action": "upsert",
"entity": "product",
"payload": [
{
"id": "7508d64f832fb06b8f82f78963b280ab",
"__code": "1111111189",
"stock": 99,
"taxId": "d390c2f211144543845dbf76fa69d17a",
"cmsPageId": null,
"deliveryTimeId": null,
"manufacturerId": null,
"unitId": null,
"price": [
{
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net": 25,
"gross": 29.75,
"linked": true
}
],
"productNumber": "1111111189",
"coverId": null,
"translations": {
"ce1df85b5f1c4eedbc532cbd34c57df6": {
"name": "Converse black",
"description": "Converse black"
},
"2fbb5fe2e29a4d70aa5854ce7ce3e20b": {
"name": "Converse black",
"description": "Converse black"
}
},
"categories": [
{
"id": "e90cf50735a0d6f69b2dbf599caa4954"
},
{
"id": "a5b4753f41c8f4bedba1bf5954c961cb"
}
],
"properties": [
{
"id": "a01a0380ca3c61428c26a231f0e49a09"
}
],
"media": [
{
"id": "cb9a886400616c215a588b13cb7c662b",
"mediaId": "a7aabb5ff4dc3c99ba45724ec7477ffe"
}
],
"parent": {
"id": "7a788255eab96bf51002829b3a6becf2",
"__code": "1111111189",
"stock": 99,
"taxId": "d390c2f211144543845dbf76fa69d17a",
"cmsPageId": null,
"deliveryTimeId": null,
"manufacturerId": null,
"unitId": null,
"price": [
{
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net": 25,
"gross": 29.75,
"linked": true
}
],
"productNumber": "converseblack",
"coverId": null,
"translations": {
"ce1df85b5f1c4eedbc532cbd34c57df6": {
"name": "Converse black",
"description": "Converse black"
},
"2fbb5fe2e29a4d70aa5854ce7ce3e20b": {
"name": "Converse black",
"description": "Converse black"
}
},
"categories": [
{
"id": "e90cf50735a0d6f69b2dbf599caa4954"
},
{
"id": "a5b4753f41c8f4bedba1bf5954c961cb"
}
],
"properties": [
{
"id": "a01a0380ca3c61428c26a231f0e49a09"
}
],
"media": [
{
"id": "cb9a886400616c215a588b13cb7c662b",
"mediaId": "a7aabb5ff4dc3c99ba45724ec7477ffe"
}
],
"configuratorSettings": [
{
"optionId": "a01a0380ca3c61428c26a231f0e49a09",
"id": "db3787abb8d6372e1997c144031ef1e2"
}
]
},
"parentId": "7a788255eab96bf51002829b3a6becf2",
"options": [
{
"id": "a01a0380ca3c61428c26a231f0e49a09"
}
]
}
]
},
"e24f994426246015347bba784ac69a97": {
"action": "upsert",
"entity": "product_visibility",
"payload": [
{
"id": "e24f994426246015347bba784ac69a97",
"productId": "7508d64f832fb06b8f82f78963b280ab",
"salesChannelId": "8e7c11e2540b4c71b521d5a59920e142",
"visibility": 30
}
]
},
"8d5a7e2b2c02986a924eaf3d9504413c": {
"action": "upsert",
"entity": "product_visibility",
"payload": [
{
"id": "8d5a7e2b2c02986a924eaf3d9504413c",
"productId": "7a788255eab96bf51002829b3a6becf2",
"salesChannelId": "8e7c11e2540b4c71b521d5a59920e142",
"visibility": 30
}
]
}
}
I have a collections of bunch of cities and zip codes, where name of a city can be a same, while zip code is different.
I'm trying to query thru all cities starting with 'San' for example and want to filter results where San Antonio appears only ones along with any other cities starting with San.
Here is a code I use:
Zipcodes.find(
{ city: { $regex: /San/, $options: 'i' } },
(err, result) => {
if (err) {
return res.send({ error: err });
}
res.send({ data: result });
},
).limit(20);
This given me following results:
{
"loc": [
-94.132581,
31.515173
],
"_id": "75972",
"city": "SAN AUGUSTINE",
"pop": 5916,
"state": "TX"
},
{
"loc": [
-98.730929,
31.162678
],
"_id": "76877",
"city": "SAN SABA",
"pop": 4023,
"state": "TX"
},
{
"loc": [
-100.481752,
31.478165
],
"_id": "76901",
"city": "SAN ANGELO",
"pop": 23800,
"state": "TX"
},
{
"loc": [
-100.480036,
31.419411
],
"_id": "76904",
"city": "SAN ANGELO",
"pop": 25535,
"state": "TX"
},
{
"loc": [
-100.390005,
31.464738
],
"_id": "76905",
"city": "SAN ANGELO",
"pop": 11284,
"state": "TX"
},
{
"loc": [
-100.438586,
31.470735
],
"_id": "76903",
"city": "SAN ANGELO",
"pop": 32471,
"state": "TX"
},
{
"loc": [
-95.034496,
29.466033
],
"_id": "77539",
"city": "SAN LEON",
"pop": 21905,
"state": "TX"
},
{
"loc": [
-99.427148,
27.062523
],
"_id": "78067",
"city": "SAN YGNACIO",
"pop": 871,
"state": "TX"
},
{
"loc": [
-98.460127,
29.414799
],
"_id": "78203",
"city": "SAN ANTONIO",
"pop": 7261,
"state": "TX"
},
{
"loc": [
-98.525967,
29.422855
],
"_id": "78207",
"city": "SAN ANTONIO",
"pop": 58355,
"state": "TX"
},
{
"loc": [
-98.5063,
29.400217
],
"_id": "78204",
"city": "SAN ANTONIO",
"pop": 11526,
"state": "TX"
},
{
"loc": [
-98.479338,
29.441338
],
"_id": "78215",
"city": "SAN ANTONIO",
"pop": 1264,
"state": "TX"
},
{
"loc": [
-98.545219,
29.358366
],
"_id": "78211",
"city": "SAN ANTONIO",
"pop": 30417,
"state": "TX"
},
{
"loc": [
-98.492509,
29.423711
],
"_id": "78205",
"city": "SAN ANTONIO",
"pop": 1714,
"state": "TX"
},
{
"loc": [
-98.497511,
29.533387
],
"_id": "78216",
"city": "SAN ANTONIO",
"pop": 30435,
"state": "TX"
},
{
"loc": [
-98.419444,
29.539525
],
"_id": "78217",
"city": "SAN ANTONIO",
"pop": 27925,
"state": "TX"
}
It's returning San Antonio many times. I need only ones.
Please help with a correct query. Thanks.
You can use $group + $replaceRoot to get values unique by city:
db.collection.aggregate([
{
$match: { city: { $regex: "San", $options: "i" } }
},
{
$group: {
_id: "$city",
doc: { $first: "$$ROOT" }
}
},
{
$replaceRoot: {
newRoot: "$doc"
}
}
])
Mongo Playground
Okay I am setting up Partial Payments via the Authorize.net API in order to enable multiple cards to be used to cover a single balance/charge.
I'm assuming thier Partial Auth feature covers my use case, but in testing, there is an issue I can show you using the API live console here: https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-credit-card
Go to the link above and authorize partial payments with the request I edited below and you will notice when you press submit you get a splitTenderId:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
},
"refId": "123456",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "462.25",
"payment": {
"creditCard": {
"cardNumber": "5424000000000015",
"expirationDate": "2020-12",
"cardCode": "999"
}
},
"lineItems": {
"lineItem": {
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
}
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "99999456654"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "emailCustomer",
"settingValue": "true"
}, {
"settingName": "allowPartialAuth",
"settingValue": "true"
},
]
},
"userFields": {
"userField": [
{
"name": "MerchantDefinedFieldName1",
"value": "MerchantDefinedFieldValue1"
},
{
"name": "favorite_color",
"value": "blue"
}
]
}
}
}
}
This is only successful because the amount is 462.25 as the docs say to use for testing, if I use any other (real) amount the splitTenderId is not there.
Here is a new example request, you can post this again on the link above:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
},
"refId": "123456",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "462",
"payment": {
"creditCard": {
"cardNumber": "5424000000000015",
"expirationDate": "2020-12",
"cardCode": "999"
}
},
"lineItems": {
"lineItem": {
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
}
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "99999456654"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "emailCustomer",
"settingValue": "true"
}, {
"settingName": "allowPartialAuth",
"settingValue": "true"
},
]
},
"userFields": {
"userField": [
{
"name": "MerchantDefinedFieldName1",
"value": "MerchantDefinedFieldValue1"
},
{
"name": "favorite_color",
"value": "blue"
}
]
}
}
}
}
And with the 462 amount entered this is no longer a partial auth payment and I no longer get a splitTenderId.
Can someone please help me figure out what is going on?