cleanResyncGhosts salesforce mobile SDK issue - javascript

When I'm trying to use cleanResyncGhosts on React Native, I'm always getting:
SyncManager$MobileSyncException: Sync (here is a number, for example 23) does not exist.
I'm getting array of sync ids for specific soup (from smartstore).
I'm doing syncDown - After that I want to iterate through an array - even if array has one sync id (I suppose that this is id of sync that was just finished), I'm getting the error and I cannot clean any ghost records...

Related

Reading Multiple Firebase Documents One By One

So in my web application, I am fetching data from firebase, it will have about 5000 documents by the time it's ready. So to reduce the number of reads, I keep an array in firebase with a list of ids of each documents, which I read and then compare with the list I have saved locally. If an id is missing, I read that particular doc from firebase (Firebase website definitely slowed down with having an array with 3000 docs so far).
However, consider the situation where I have 2000+ docs missing and I have to fetch them one by one according to missingList I created from comparing the firebase and local arrays. It is heck a lot of slow, it takes so long to fetch even a hundred documents because I am using await. If I don't, then firebase is overloaded with requests and for some reason it shows a warning that my net is disconnected.
What is the best way to fetch documents with ids given in an array, with no loss and reasonably fast enough? Is there a way for me to batch read documents like there is batch write, update and set?
Say Firebase has [1234, 1235, 1236, 1237] and I only have [1234] so I need to read [1235, 1236, 1237] from it.
I am using a for loop to iterate through each id and get the corresponding document like so
for (let i = 0; i < missingList.length; i++) {
var item = await db.collection('myCollection').doc(missingList[i]).get().then((snapshot) => snapshot.data())
await saveToDB(item) //I use PouchDB for local storage
}
The closest thing to a 'batched read' in Firestore is a transaction, but using a transation to read hundreds of document is not really efficient. Instead, I suggest you add one field to every document, like token. Then, every time you get data for the first time, generate a random token client-side, then write it to every document that you read. After that, if you detect a change in the list of ids you mention above, run a query on that token field, like :
db.collection('myCollection').where('token', '!=', locallySavedToken).get()
Remember to write your local token back to the read documents. This way, your query time will be much faster. The down side is you need 1 extra write request for every document read. If you need to re-read your data a lot then maybe look into transactions, since write requests pricing is more expensive than read requests

Why don't I have any JSON showing and a 403 message?

I completely new to Strapi. However, I have used Vue CLI many times before.
I am following this tutorial on how to use the two platforms together [https://blog.logrocket.com/how-to-build-an-ecommerce-site-with-strapi-vue-js-and-flutterwave/][1].
After creating a list of products within Strapi, as in the tutorial, when I navigate to 'localhost:1337/products' I do not see any json being produced. Instead, I am presented with the following message:
{"statusCode":403,"error":"Forbidden","message":"Forbidden"}
My Vue v-for loop reports that my data is undefined as a result.
Any help welcome.
This had to do with Strapi Roles & Permissions. Once updated the data then worked.

Empty key fields for MaterialBOMItem of API_BILL_OF_MATERIAL_SRV Version 2 using SAP Cloud SDK JavaScript

I am trying to update/delete a bill of material item using the SAP Cloud SDK JavaScript (version 1.12.0).
The item belongs to a group BOM, i.e. the property "plant" is an empty string.
This results in the following self-explaining error message (example for PATCH request):
Error: OData update request failed!
...
Caused by:
Error: patch request to https://<host>:<port>/sap/opu/odata/sap/API_BILL_OF_MATERIAL_SRV;v=0002 $failed!
...
Caused by:
Error: The value: of the key: Plant is not nullable, please set the value.
...
This behaviour is consistent with the documentation of the entity MaterialBOMItem of the service API_BILL_OF_MATERIAL_SRV (Version 2) (https://api.sap.com/api/API_BILL_OF_MATERIAL_SRV_0002/resource)
where updating and removing entities of MaterialBOMItem require "Plant" and some other fields.
In detail, this affects the routes PATCH and DELETE which require these properties: BillOfMaterial, BillOfMaterialCategory, BillOfMaterialVariant, BillOfMaterialVersion, BillOfMaterialItemNodeNumber, HeaderChangeDocument, Material, Plant.
For some of them an empty value may be valid (e.g. empty plant for group BOM).
However, although "Plant" is marked as required it can be left empty
when using the PATCH/UPDATE endpoints of API_BILL_OF_MATERIAL_SRV. This way I can update/delete a group BOM item.
Should the SDK support this behaviour as well?
Thank you for bringing this to our attention and for your comprehensive description of the issue. Yes, the SDK should support this. We fixed this bug and you should be able to use it with the next version (available ~2 weeks from now).

How to parse error with Square Connect API example (Node)

I am trying to learn how to process payments with Square, and am trying to run their examples from GitHub to get a feel regarding how to structure the payments application. I built the node example from here: https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/node_payment using npm install and npm build to get the app up and running.
I am using "4532759734545858" for the card number, "123" for CVV, "0120" for expiration, and "94103" for the zip. I got the card number from here: https://docs.connect.squareup.com/articles/using-sandbox where it states that this is a good number to use for a Visa sandbox.
Also, I have updated the config.json with properties from my developer settings.
When trying to process a payment a get a DOM element that says "Card Declined" without further specifying the error. Is there something I can do to parse the error?
Based on the documentation at: https://docs.connect.squareup.com/articles/using-sandbox#generatingerrorstates it seems the amount_money field of the request is not being populated, but I am having trouble confirming.
Ideally I would like to get to a point where I can add a card as a hash value to my db and use it for recurring billing...
That "card declined" message is actually the error you get back from Square's APIs. You can play around with the error messaging in the app.js file and the `error.jade. Try error.catagory, code, detail.
Keep in mind that this is just a sample app, to show that you can use the APIs with node.js, you probably don't want to use this code in your production system.

Ionic 2 + AngularFire2 (TypeScript/JavaScript): Not able to properly iterate over Array

I am currently using Ionic 2 (which is based on Angular 2) to develop a Progressive Web Application about food and restaurants.
I use Firebase to manage my Users and more generaly as a way to save my data.
I also use the AngularFire2 library to communicate with Firebase.
The problem I am having right now is that have a list of dishes that my clients prefer that is saved in FireBase and I want to retrieve that in order to manipulate the data and use it in a certain algorithm to be able to make propositions on what menus the client could want to eat today.
I use this code to iterate over the FirebaseListObservable that has the user's preferences:
this.af.database.list('/users/'+this.authentificationService.getUserId()+'/favs')
.subscribe(snapshots=>{
snapshots.forEach(snapshot => {
this.prefList.push(snapshot.label);
});
});
console.log(this.prefList);
And you can see that I push the values in that Observable into a list named prefList that I declared as follows:
public prefList: String[]=[];
The console.log(this.prefList) line gives me this result (as seen from Chrome's inspect >> console) As you can see the array isn't empty.
console.log(this.pref)
The problem is that I cannot iterate over the prefList because the length seems to always be 0. I tried with this.pref[0] aswell but this time I get Undefined. I really can't see a way to solve this. Please help?

Categories

Resources