I have the following query on graphql
query articles {
articles {
news_link
article_details {
description
title
brands {
name
}
featured_image {
url
}
published_at
}
}
}
Which will give me the following sample response
{
"data": {
"articles": [
{
"news_link": "http://loanstreet.com.my",
"article_details": [
{
"description": "My first article",
"title": "First Article",
"brands": [
{
"name": "Fendi"
}
],
"featured_image": {
"url": "/uploads/e5c00dbd3a3648dd8c0e1c2a44f50c0d.png"
},
"published_at": "2020-03-31T04:00:00.000Z"
},
{
"description": "Lighter ff article",
"title": "First Article LP",
"brands": [
{
"name": "Lighter"
}
],
"featured_image": {
"url": "/uploads/ac6c5f26050f46eebd37fa7319ab531b.png"
},
"published_at": "2020-03-31T04:00:00.000Z"
}
]
}
]
}
}
I am trying to query and only get the response where brand name is "Fendi" but cannot seem to get it right using Graphql playground.
I tried this
query articles {
articles {
news_link
article_details {
description
title
brands(where: {name: "Fendi"}) {
name
}
featured_image {
url
}
published_at
}
}
}
but it gave me this response which is not really what i want
{
"data": {
"articles": [
{
"news_link": "http://loanstreet.com.my",
"article_details": [
{
"description": "My first article",
"title": "First Article",
"brands": [
{
"name": "Fendi"
}
],
"featured_image": {
"url": "/uploads/e5c00dbd3a3648dd8c0e1c2a44f50c0d.png"
},
"published_at": "2020-03-31T04:00:00.000Z"
},
{
"description": "Lighter ff article",
"title": "First Article LP",
"brands": [],
"featured_image": {
"url": "/uploads/ac6c5f26050f46eebd37fa7319ab531b.png"
},
"published_at": "2020-03-31T04:00:00.000Z"
}
]
}
]
}
}
I am expecting a response like this
{
"data": {
"articles": [
{
"news_link": "http://loanstreet.com.my",
"article_details": [
{
"description": "My first article",
"title": "First Article",
"brands": [
{
"name": "Fendi"
}
],
"featured_image": {
"url": "/uploads/e5c00dbd3a3648dd8c0e1c2a44f50c0d.png"
},
"published_at": "2020-03-31T04:00:00.000Z"
}
]
}
]
}
}
Any help is appreciated. Thanks
Related
I use bot to post cards with version 2 (сards_v2 property).
Cards are rendered as normal, but I want to add a Button to open Dialog. This does not work.
How can I achieve this?
I post to POST /v1/chat/channels/:channel_id/messages?
body:
{
"cards_v2": [{
"card": {
"header": {
"title": "Rolodex",
"subtitle": "Manage your contacts!",
"imageType": "CIRCLE",
"imageUrl": "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png"
},
"sections": [{
"widgets": [{
"buttonList": {
"buttons": [{
"text": "Add Contact",
"onClick": {
"action": {
"function": "openDialog",
"interaction": "OPEN_DIALOG"
}
}
}]
}
}]
}]
}
}]
}
Then I click on Button, and receive event:
{
"type": "CARD_CLICKED",
"eventTime": "2022-08-31T16:16:36.147391Z",
"message": {
"name": "spaces/:space_id/messages/YTyNVBNW-H4.YTyNVBNW-H4",
"sender": { ... },
"createTime": "2022-08-31T16:16:31.639439Z",
"thread": { ... },
"space": { ... },
"cardsV2": [{
"card": {
"header": {
"title": "Rolodex",
"subtitle": "Manage your contacts!",
"imageType": "CIRCLE",
"imageUrl": "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png"
},
"sections": [{
"widgets": [{
"buttonList": {
"buttons": [{
"text": "Add Contact",
"onClick": {
"action": {
"function": "openDialog"
}
}
}]
}
}]
}]
}
}],
"retentionSettings": {
"state": "PERMANENT"
}
},
"user": { ... },
"space": { ... },
"action": {
"actionMethodName": "openDialog"
},
"common": {
"hostApp": "CHAT",
"invokedFunction": "openDialog"
}
}
First: Event skips DialogEventType is REQUEST_DIALOG.
Second: When I respond with dialog response, but no dialog appears.
{
"actionResponse": {
"type": "DIALOG",
"dialogAction": {
"dialog": {
"body": {
"sections": [{
"header": "Add new contact",
"widgets": [{
"textInput": {
"name": "contactName",
"label": "Name",
"type": "SINGLE_LINE"
}
}, {
"buttonList": {
"buttons": [{
"text": "Next",
"onClick": {
"action": {
"function": "openSequentialDialog"
}
}
}]
}
}]
}]
}
}
}
}
}
I see only error:
We are tring to enrich a profil using UpdateProperties event.
Something wrong, it didn't work.
Step of our process :
Search of the profil :
Use of the prive API /profiles/search
So we find a profil and get the profilId "60de10fe-e6ff-11ec-8fea-0242ac120002" for next step.
Enrich profil :
Use of the API public /context.json to post the json
{
"sessionId": null,
"profileId": "60de10fe-e6ff-11ec-8fea-0242ac120002",
"events": [
{
"itemType": "event",
"scope": "myScope",
"eventType": "updateProperties",
"properties": {
"update": {
"properties.age": "24"
},
"add": {
"properties.kids" : "1"
}
}
}
]
}
Response :
{
"profileId": "60de10fe-e6ff-11ec-8fea-0242ac120002",
"sessionId": null,
"profileProperties": null,
"sessionProperties": null,
"profileSegments": null,
"profileScores": null,
"filteringResults": null,
"processedEvents": 1,
"personalizations": null,
"trackedConditions": [
{
"parameterValues": {
"operator": "and",
"subConditions": [
{
"parameterValues": {
"formId": "zoneLeadFormEvent"
},
"type": "formEventCondition"
}
]
},
"type": "booleanCondition"
},
{
"parameterValues": {
"formId": "testFormTracking",
"pagePath": "/tracker/"
},
"type": "formEventCondition"
},
{
"parameterValues": {
"formId": "searchForm"
},
"type": "formEventCondition"
},
{
"parameterValues": {
"formId": "advancedSearchForm"
},
"type": "formEventCondition"
}
],
"anonymousBrowsing": false,
"consents": {}
}
Validation of the profile changes
Get /cxs/profiles/60de10fe-e6ff-11ec-8fea-0242ac120002
So, the properties are not updated.
We use a rules the merge the profil on a custom identifier :
{
"metadata": {
"id": "update_with_custom_identifier",
"name": "UpdateWithCustomIdentifier",
"description": "Copy my properties to profile properties on update"
},
"condition": {
"parameterValues": {
"subConditions": [
{
"parameterValues": {
},
"type": "updatePropertiesEventCondition"
}
],
"operator": "and"
},
"type": "booleanCondition"
},
"actions": [
{
"parameterValues": {
"mergeProfilePropertyValue": "eventProperty::target.properties.myIdentifier",
"mergeProfilePropertyName": "mergeCustomIdentifier"
},
"type": "mergeProfilesOnPropertyAction"
},
{
"parameterValues": {
},
"type": "allEventToProfilePropertiesAction"
}
]
}
What's the good method ?
Thanks in advance
I'm new to MongoDB, and I'm not sure if what I'm trying to do is possible at all. I've exhausted my Google skills, so I'm hoping someone here can give me a push in the right direction.
My data is structured like this:
db={
"people": [
{
"id": 1,
"name": "Pete",
"occupation": "baker"
},
{
"id": 2,
"name": "Mike",
"occupation": "painter"
}
],
"activity": [
{
"baker": "bakes",
"painter": "paints"
}
]
}
Although this is just sample data, my "activity" is a single large document with unique keys that I'm trying to get the value from, based on key name (when it matches value from the "people" document).
What I'm trying to achieve is this output:
[
{
"id": 1,
"name": "Pete",
"occupation": "baker”,
“activity:” “bakes”
},
{
"id": 2,
"name": "Mike",
"occupation": "painter”,
“activity”: “paints”
}
]
Is this possible at all?
If I understand your database and data model, it seems like a poor model.
If the data model was different (see below), the query would be quite simple. Given that, here's one way you could generate your desired output with your model.
db.people.aggregate([
{ "$lookup": {
"from": "activity",
"let": { occ: "$occupation" },
"pipeline": [
{
"$replaceWith": {
"$arrayToObject": {
"$filter": {
"input": { "$objectToArray": "$$ROOT" },
"as": "kv",
"cond": { "$eq": [ "$$kv.k", "$$occ" ] }
}
}
}
}
],
"as": "activity"
}
},
{ "$set": {
"activity": {
"$getField": {
"field": "v",
"input": {
"$first": {
"$objectToArray": { "$first": "$activity" }
}
}
}
}
}
},
{ "$unset": "_id" }
])
Try it on mongoplayground.net.
If your activity collection has this model...
[
{
"occupation": "baker",
"activity": "bakes"
},
{
"occupation": "painter",
"activity": "paints"
}
]
... then the query could be:
db.people.aggregate([
{ "$lookup": {
"from": "activity",
"localField": "occupation",
"foreignField": "occupation",
"as": "activity"
}
},
{ "$set": { "activity": { "$first": "$activity.activity" } } },
{ "$unset": "_id" }
])
Try it on mongoplayground.net.
I'm trying to create a new spreadsheet using spreadsheets#create, with specified row groups.
In the API Explorer, I am entering in the JSON below. which corresponds to the following appearance:
No errors are flagged or returned when I execute the call, but when the sheet is created, the specified grouping is not created - only the values are set.
{ "properties": {
"title": "Test Spreadsheet",
"locale": "en"
},
"sheets": [
{ "properties": {"title": "Test1"},
"data": [
{
"startRow": 0,
"startColumn": 0,
"rowData": [
{ "values": [
{ "userEnteredValue": { "stringValue": "Top1" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "Top2" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "" } },
{ "userEnteredValue": { "stringValue": "Top2A" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "" } },
{ "userEnteredValue": { "stringValue": "Top2B" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "" } },
{ "userEnteredValue": { "stringValue": "Top2C" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "Top3" } }
]
}
]
}
],
"rowGroups": [
{ "range": {
"dimension": "ROWS",
"startIndex": 2,
"endIndex": 5
}
}
]
}
]
}
Even when I create the rowGroups JSON directly on the page, with its structured editor to make sure it is properly defined, the created spreadsheet still doesn't group the specified rows. I have triple-checked all my objects from the top down, and can't see what I am doing wrong.
I have a user like so:
{
"_id": "u88888",
"_rev": "27-9f205fb7496645be2f3d717fff376d73",
"name": "Test Testerson",
"type": "user",
"role": "boss",
"training": [
{
"id": "11111",
"name": "training 1"
},
{
"id": "33333",
"name": "training 3"
}
]
}
I'm trying to run a query to find the following:
Is a type, "user"
Has a role of "boss"
Does not have the training of id: "11111"
I do the following selector, however, this user comes up and I'm not sure why:
selector:{
"$and": [
{ "type": "user" },
{ "role": "boss" },
{ "training": { "$ne": { "id": "11111" } } }
]
}
Found an answer. This ended up working:
{ training: { $not: {$elemMatch: {id: "11111" } } }