I'm currently building a sapui5 app with odata. This app has to work offline, however everytime I try to set up a new entity with createEntry, the entry is not created until I run odataModel.submitchanges which performs a PUT request.
How are entries supposed to be correctly created in a offline scenario?
I'm not sure but you should be able to write a json model and use it as odata request. Like this
var mydata = {
"milk": [{
"Store Name": "XXXXXXXXXX",
"Revenue": 321421,
"Cost": 200,
"Consumption": 2321.4
},
{
"Store Name": "AAAAAAAa",
"Revenue": 4550208.3173505,
"Cost": 100,
"Consumption": 493776.33
}]
}
var oModel = new JSONModel();
oModel.setData(myData);
after that you should be able to use this model.
Related
I want to modify the response of hasura fetch query.
the current response is this:
{
"data": {
"ids": [
{
"id_object": {
"id": 33102
}
},
{
"id_object": {
"id": 33104
}
}
]
}
}
And I want to remove "id_object" and want just array of id's like this:
{
"data": {
"ids": [
{
"id": 33102
},
{
"id": 33104
}
]
}
}
A GraphQL server exposes an exact set of operations and the shape of the allowed responses for those operations. When interacting with any GraphQL server (Hasura or otherwise), it is therefore not possible to to arbitrarily modify the shape of the returned data.
You're free to map it into a new form when you receive the data on the client side.
If you really need the server itself to be able to respond using this shape, you'll need to extend Hasura's schema to be able to specifically support this query pattern.
There are a number of different ways that you could accomplish this:
You could write a custom Hasura Action
You could expose this query from your own GraphQL server and then stitch it together with Hasura using Remote Schemas
You could use a Postgres View or Function to shape the data as required and expose it as a new operation
I implemented with Graph API several calls to create a document set.
I followed the answer posted here concerning the possibility of creating a DocumentSet in SharePoint here : Is it possible to create a project documentset using graph API?
For this i followed those steps :
1. Getting the library driveId :
`GET https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}?$expand=drive`
2. Creating the folder:
POST https://graph.microsoft.com/v1.0/drives/${driveId}/root/children
I have to pass an object:
{
"name": ${nameOfTheFolder},
"folder": {},
}
3. Getting the Sharepoint itemId:
4. Updating the document library:
`PATCH https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/items/${sharepointIds.listItemId}`
and passing a body:
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
I have questions concerning the folder creation and the updating:
What is expected in the folder object ?
{
"name": ${nameOfTheFolder},
"folder": {},
}
Concerning the path step:
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
I have several questions :
Let's consider i have a document type called invoices. Which id is expected for document type id ?
finally how do i pass the fields ? let's say i want to pass 3 fields : invoiceId, claimId, clientId.
Graph API is great but some more information would be helpful. thanks !
I have questions concerning the folder creation and the updating: What is expected in the folder object ?
The folder object (sent as {}) is there to tell graph API that you are creating a folder and not a file. It is a property of the drive item
Let's consider i have a document type called invoices. Which id is expected for document type id ?
This is the id contentType subfield of the list item you are patching
ally how do i pass the fields ? let's say i want to pass 3 fields : invoiceId, claimId, clientId.
You just pass them with repective values like below. See Update listItem
{
"invoiceId": "value",
"claimId": "value"
...
}
One point I didn't express correctly was to know what id is expected here :
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
I retrieved the different content types of my site by calling this kind of URL and check if the content type exists.
https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/contentTypes
From the result i retrieve in a Value object the id.
The id looks like this :
0x0120D5200082903AB771604546844DB2AC483D905B00E58445A7D..........
In modern SharePoint, you can also get the Content Type ID from the UI by browsing to SharePoint Site > Site Settings > Site content types > <ContentTypeName> > Content Type ID.
Content Type ID
Not sure if this is easier than via graph, but it's another option at least.
As part of creating a Team in Microsoft teams using the Graph API, I'm trying to create a folder in Microsoft Graph with a custom column - just a simple yes/no.
This is what I have so far:
var newFolder = new DriveItem();
newFolder.Name = folderName;
newFolder.Folder = new Folder();
newFolder.AdditionalData = new Dictionary<string, object>();
newFolder.AdditionalData.Add("#microsoft.graph.conflictBehavior", "rename");
var newSubFolder = _graphClient.Groups[team.RemoteId].Drive.Items[parentFolder.RemoteId].Children
.Request().AddAsync(newFolder).Result;
However I need to add a custom column to this folder at creation time (or just after, if it needs to be in an update call). I was hoping I could do this easily through the Graph API but I can't seem to find any way to do this. Does anyone know how? (I have no idea how to access the underlying SharePoint API, by the way, so even if I knew how to do it with SharePoint that wouldn't help me much at the moment.)
Try the following steps:
(1) Create the folder:
POST /drives/{drive-id}/items/root/children
{ "name": "{test}", "folder": { }, "#microsoft.graph.conflictBehavior": "fail" }
(2) Get the created folder's item id and update the folder's content type, metadata:
PATCH /sites/{site-id}/lists/{library-name}/items/{item-id} { "contentType": { "id": "{content-type-id}" }, "fields": { "fieldname1": "{value}", "fieldname": "{value}" } }
I work with firebase database, I have the following data,
I need to get all groups names (GName) of a user by his phoneNum, i.e. all groups of specific user, How can I get that in swift 4?
You should consider restructuring your data. If a user belongs to more than one group in your application then you'll probably have to duplicate your user node for every group the user belongs to in your data structure. You can create another JSON object that holds all of the groups that a user belongs to. Here is a sample JSON for you:
{
"users": [{
"xyz123": {
"userId": "xyz123",
"username": "user1",
"phoneNum": "123456",
"groups": [{
"groupId": 1,
"groupName": "aaa"
}, {
"groupId": 2,
"groupName": "bbb"
}]
}
}]
}
As for filtering with the phone number, you can get all users inside a list and filter the result with the phone number criteria
result = result.filter({item.phoneNum == "123456"})
or get phone number of the user to a upper level, call .child() method with the phone number criteria and fetch the specific user.
Also take a look at structuring data part at firebase documentation.
https://firebase.google.com/docs/database/ios/structure-data
Hope that helps.
I have a rest webservice that gets me the a json response in the following structure :
{
"Categories": [
{
"category_id":1,
"category_name":"category 1"
},
{
"category_id":2,
"category_name":"category 2"
}
],
"Products":[
{
"product_id":1,
"product_name":"Product 1",
"category_id":1
},
{
"product_id":2,
"product_name":"Product 2",
"category_id":1
},
{
"product_id":3,
"product_name":"Product 3",
"category_id":2
}
]
}
I am creating a Core data model for my iOS application in which i can save this data as you can see below .
The problem is how can I use the relationships that I have created in my core data model to map this data?
The silliest idea that comes to my mind is to search for each product's category based on the category id and then set it like
Product.category = category [i] , but there got to be a easier way to do this.
Based on your use of ObjectMapper you will need to make the connections yourself using your 'silly idea (TM)'. You should look at doing the fetch as a batch and sorting the results to minimise calls to Core Data and to make the mapping simple.
If you chose to use RestKit then you could just configure the mappings for the objects and the identities used to link them and RestKit will do the lifting work. It could be a bit of work for you...