Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 349
» Latest member: customrubber
» Forum threads: 240
» Forum posts: 1,069

Full Statistics

Online Users
There are currently 52 online users.
» 0 Member(s) | 50 Guest(s)
Bing, Google

Latest Threads
using cdb_auth with Live...
Forum: General
Last Post: JereMiami
12-19-2024, 01:58 AM
» Replies: 0
» Views: 31
BLOBs - not possible to a...
Forum: General
Last Post: stamatis
10-06-2024, 06:28 PM
» Replies: 0
» Views: 262
Allow users to change the...
Forum: General
Last Post: mark_talluto
01-18-2024, 01:09 AM
» Replies: 8
» Views: 11,442
cdb_sendEmail
Forum: General
Last Post: mark_talluto
11-07-2023, 09:57 PM
» Replies: 0
» Views: 688
cdb_sync & cdb_lookupvalu...
Forum: General
Last Post: mark_talluto
11-07-2023, 09:45 PM
» Replies: 1
» Views: 1,241
cdb cdb_sendEmail
Forum: Bug Reports
Last Post: JereMiami
10-05-2023, 01:57 PM
» Replies: 0
» Views: 1,770
LCM: "Please inform Canel...
Forum: General
Last Post: mark_talluto
07-12-2023, 07:58 PM
» Replies: 24
» Views: 23,252
San Franciso Region Outag...
Forum: Announcements
Last Post: mark_talluto
05-09-2023, 03:31 AM
» Replies: 1
» Views: 2,880
Error, CDB_Header checksu...
Forum: General
Last Post: cpuandnet
02-01-2023, 05:00 AM
» Replies: 4
» Views: 3,935
CDBCache sync from local ...
Forum: General
Last Post: Hendricus
01-29-2023, 09:39 PM
» Replies: 2
» Views: 2,779

 
  Unicode
Posted by: Pebah - 06-25-2020, 07:31 PM - Forum: General - Replies (5)

Hi, is LiveCloud Unicode compliant? Currently (not using LiveCloud yet) I'm storing my text data in arrays as html text. However, to do queries, I suppose it needs to be plain text. I'm dealing with English with diacriticals and Chinese characters. Will I have any issues changing the text storage method?


  cdb_update changed/new data - best practices
Posted by: mark_talluto - 06-09-2020, 07:55 PM - Forum: Code Samples - Replies (1)

One of our beloved LiveCloud developers asked a great question about cdb_update. He wanted to know how to efficiently update only data that has changed. Below is a copy of the email response. Please let us know if you have any questions about this solution.

Suppose the following array (record):

tInputA =
[“firstName”]
[“lastName”]
[“age”]
[“phone”]

Existing record id "435756d6-0576-4a86-8d01-7557168f6528" contains:

firstName: Tom
lastName: Perkins
age: 78
Phone: 123-456-7890

If you pass an array like: 
tInputA =
[“firstName”][“Tom”]
[“lastName”][“Perkins”]
[“age”][“78”]
[“phone”][“555-888-9999”]

This will push an update to all the keys in this array even though some of the data may not have changed.

If you pass an array like:
tInputA =
[“phone”][“555-888-9999”]

You are only touching the “phone” key. The other data will stay as it is. The cloud call will be smaller and more efficient (...marginally). The question is how do you know that the phone data has has been updated?

It sounds like you are looking to come up with a method to pass as little data as possible (optimization) by determining what has changed.
This can be an important optimization if your array contains many keys. Or, it you may have heavy data in some of the keys. LiveCloud is not able to determine what is new for you without making a round trip to the cloud and compare. Solving this in your app is best.

People solve this problem in different ways.

Method #1: Develop a flag system to track which fields have been touched by your app
Method #2: Use the set operations in LiveCode to compare the original array with the final version and see if changes have been made
Method #3: Send the full array up using cdb_update and let LiveCloud push both new and old data into place
Method #4: Pick up the changes in a field and call cdb_update as each field is updated with: closeField

I am going to supply you the code to do Method #2 as it is not always apparent how to do this. 
Drop this code into a single button. Put breakpoints into the code so you can walk through it. Once you get the hang of it, you can use this API in your own code.


—COPY ALL THE CODE BELOW TO A SINGLE BUTTON IN LIVECODE
//>GLOBALS
global gArrayA1, gArrayA2


on mouseUp
     local tInputA, tRecordID
     
     --BUILD THE TWO ARRAYS TO COMPARE
     buildArray1
     buildArray2
     
     --CALL CUSTOM API TO COMPARE THE TWO ARRAYS
     put compareTwoArrays(gArrayA1,gArrayA2) into tInputA
     
     --WE NEED TO CONVERT THIS ARRAY
     --THE KEY AND VALUE NEED TO BE IN THE RIGHT PLACE
     combine tInputA with lf and empty
     split tInputA with lf and comma

     --RECORD TO BE UPDATED
     put "435756d6-0576-4a86-8d01-7557168f6528" into tRecordID
     
     --DO CLOUD UPDATE
     cdb_update tInputA,"myTableName", tRecordID
end mouseUp


function compareTwoArrays pArray1, pArray2
     local tArrayA3
     
     /* BREAKPOINT THROUGH THIS TO SEE WHAT IS HAPPENING STEP BY STEP */
     
     --TURN ARRAYS INTO A STRING
     --WE ARE TAKING THE ELEMENT AND ITS VALUE AND SMASHING THEM TOGETHER
     --gArrayA1 WOULD BE YOUR CURRENT CLOUD OR LOCAL RECORD
     --gArrayA2 WOULD BE THE ARRAY CAPTURED FROM YOUR APP THAT MAY HAVE NEW OR UPDATED DATA
     combine pArray1 with lf and comma
     combine pArray2 with lf and comma
     
     --TURN STRING BACK INTO AN ARRAY
     --WE WANT THE COMBINED KEY AND VALUE TO BE THE NEW ELEMENT
     --THIS WILL MAKE IT EASY TO COMPARE THE TWO ARRAYS
     --IT IS INTENDED THAT THE VALUE WILL BE EMPTY
     split pArray1 with lf and empty
     split pArray2 with lf and empty
     
     --WE DO A SET OPERATION TO FIND WHICH DATA IS NEW
     --DIFFERENCE IS ONLY LOOKING AT THE ELEMENT, NOT THE VALUE OF THE KEY WHEN DOING ITS OPERATION
     --WHATEVER IS LEFT IN THE tArrayA3 ARRAY IS NEW
     difference pArray2 with pArray1 into tArrayA3
     
     return tArrayA3
end compareTwoArrays


on buildArray1
     /* CHANGE THIS ARRAY TO MATCH YOUR TABLE */
     put "Tom" into gArrayA1["firstName"]
     put "Perkins" into gArrayA1["lastName"]
     put "78" into gArrayA1["age"]
     put "123-456-7890" into gArrayA1["phone"]
end buildArray1


on buildArray2
     /* CHANGE THIS ARRAY TO MATCH YOUR TABLE */
     put "555-888-0000" into gArrayA2["phone"]
end buildArray2


  searcheable / queryable arrays stored in keys?
Posted by: sid - 05-16-2020, 03:30 AM - Forum: General - Replies (2)

Hi Guys

this is more a question im sure a lot of devs will ask.

If a dev decides to store arrays in a key within livecloud, is it then possible to run a query on the database and include results that are within the array key?

for example, if I were to store invoices as a DGData array in a key called invData, and 3 of the keys in within the stored array is productBought =20 , Customer = Sid, Item=Mask

I want to run a query looking for invoices that were made out to Sid for masks , and want only invoices where he bought over 10 masks.

this is really easy to do if each line item is stored seperately in the livecloud database, but if you store the invoice data as and array key within a key in the database , can it work?

the upside to being able to do this is that the database is nice and compact with each invoice or whatever taking up a single record ,

the downside is the queries being difficult to do, if its possible at all

The upside to storing all the line items as seperate records is the ease of search, and the ability to run really cool queries.
the downside being that individual line items will take up a record and be scattered all over the plave, resulting in zillions of records and writes to the database

Sid


  LiveCloud website updated
Posted by: mark_talluto - 05-04-2020, 05:40 PM - Forum: Announcements - No Replies

Hi Everyone. I apologize for the LiveCloud site going down. We have been updating the site and broke it in the process. The website is fully updated and running well at this point. 

We want to stress that the website and LiveCloud's network are not connected. The LiveCloud regions were not affected by the website's outage.


  CanelaDB SDK Missing
Posted by: TomNguyen - 04-17-2020, 04:06 PM - Forum: General - Replies (3)

Hello

I am new to Livecloud.  I can not seem to find the API and the Data folder after I Exported the Toolkit  from Livecloud Manager.   However CanelaDB and subdirectry Libraries and Config is created.  Anyone had  the same problem and have the solution please help.  Thank you.


  cdb_addTableToProject
Posted by: JereMiami - 04-17-2020, 02:12 PM - Forum: General - Replies (1)

I am logged in with my developer credentials. I would like to copy (or add) a table within this project to another project. However, I receive the following message: "The table you are trying to add does not exist."

To be more specific: I am trying to link TableA from ProjectX to ProjectY, where the result is TableA is linked to both ProjectX and ProjectY

Is cdb_addTableToProject the command I should use (cdb_addTableToProject "ProjectY","TableA")?

Thanks-


(04-17-2020, 02:12 PM)JereMiami Wrote: I am logged in with my developer credentials. I would like to copy (or add) a table within this project to another project. However, I receive the following message: "The table you are trying to add does not exist."

To be more specific: I am trying to link TableA from ProjectX to ProjectY, where the result is TableA is linked to both ProjectX and ProjectY

Is cdb_addTableToProject the command I should use (cdb_addTableToProject "ProjectY","TableA")?

Thanks-

Nevermind: use cdbLoadTable prior to cdb_addTableToProject  

Wink


  Version 2.6.2 released
Posted by: mark_talluto - 04-16-2020, 05:11 PM - Forum: Announcements - No Replies

This is an interesting update that will affect you at some point. Here is the scenario that brought this to our attention.

We are working on Appli and using LiveCloud Manager on the same computer. Sound familiar? It should as I bet most of you are doing this too.

If you sign in with the same credientials (developer on both apps), you run the risk of your app getting an updated API authentication key. LiveCloud Manager would then be denied access to the data because the same credentials are now using a new API auth key.

LCM did not deal with this situation nicely. The solution was to have LCM recognize that this happened and have it re-auth to get the updated API. To do this, we needed to make the gCSIauthA variable global. We could then have LCM try to auth again when the it ran into the problem. LCM could then continue doing what it needed to do.

Under normal circumstances, your clients would never be able to see this. This will only affect the developers that have an app they are developing open and LCM on the same computer. And, the app would need to have forced a new API key. 

Here is an example of how LCM is handling this when it does a cdb_SDK() call:

get cdb_SDK("myProject")
if not cdb_result() then
    if gCDBresultA["recent"]["response"] = "Error: Failed API Key Authentication" then
         get cdb_auth (gCSIauthA["email"],gCSIauthA["password"],"developer")
         get cdb_SDK("myProject")
         if not cdb_result() then
              return empty --YOU MAY WANT TO HAVE YOUR SOFTWARE GRACEFULLY RETURN TO THE LOGIN SCREEN
         end if
    end if
end if

Some extra thoughts:
You might find that this would have to be littered in many places. This solution is not practical. While our current solution works for our particular case, we may need to improve this further. One consideration is to have a callback for this situation.

You would get a new API that allows you to set the name of the handler to call when the callBack happens. We could then catch this problem reliably in all cases and then deal with it in one place. You would not need to place the example code above everywhere.

The steps we have taken so far allow LCM to work and lays the groundwork to do the full callBack solution.


  Version 2.6.1 released
Posted by: mark_talluto - 04-16-2020, 04:50 PM - Forum: Announcements - No Replies

The update contains a fix to LCM that fixes an issue where we could not delete a project that had more than one word in the name. I think it is a bug in LiveCode that can not deal with sending a word that is also a valid token in LiveCode as a parameter.

Should you need to do that, the solution we came up with was to base64Encode the value before passing it. Should this turn out to be a LiveCode bug, we will generate a bug report.


  Blobs and Datagrids
Posted by: sid - 04-12-2020, 12:52 PM - Forum: Code Samples - Replies (2)

Hi Guys

I have a few questions on BLOBS and datagrids and will appreciate some sample code here.

I have managed to create a form with a datagrid on it , and a image object that retrieves the images from the cloud when a user hilites a line on the grid. This is designed as a cloudcall and not a local call , so its a tad slow.

here is a vid on how this works : https://www.loom.com/share/d609c74551df48309f51723192353039

here is the code:

Code:
local  tBlobGridRef, tPathToBlob, theLine, theSelectedID, tPHtender

getProp uSelectedPicID
 
  put the dgHilitedLines of me into theLine
  return GetDataOfLine(theLine,"blobReference")
 
end uSelectedPicID


on selectionChanged pHilitedIndex, pPrevHilitedIndex
 
  show widget "PHSpinner"
  put empty into tBlobGridRef
  put empty into tPathToBlob
 
  put the uSelectedPicID of group "Tenders" into theSelectedID
  put cdb_readBlob(theSelectedID,"cloud") into tPathToBlob
  set the filename of image "tenderPicViewer" to tPathToBlob
  //set the text of image "tenderPicViewer" to tPathToBlob
  put the text of image "PHTender" into tPHtender
  if tPathToBlob is empty then set the text of image "tenderPicViewer" to tPHtender
  hide widget "PHSpinner"
 
end selectionChanged
 

Here is  question 1. Its a cloud call but the path to the image ends up being a local path? Its pretty slow ,( perhaps because I'm living in a rural farm town) Does the system download the image if its a cloud based call or just look in the local Blobs table if it exists?

so I tried to resize all images to under 10kb and that helped a lot. Much faster, so I tried to put the text of the image into a table key, (not a BLOB table) figuring I can just store the text into the key and then that should speed it up more if its just a 100x80 pixel .png thumbnail. LCM did not seem to allow this? can we actually do that? Or will it totally mess up the performance?

Question 3 , Is it possible to put a thumbnail of a BLOB into a DataGrid? and if so, is it possible to only load the images that will be visible to the user (IE. only when the lines are visible on his screen. Will appreciate some help with this.
I am designing a system with at least 70000 product items and God help a tablet trying to load ...lets say 30000 thumbnails if a query is run. It will probably die...although it will be interesting to test. So the idea is run a LCM Query and put the results into a DataGrid table with a BLOB in one of the columns.

Question 4. Is it possible to have more than 1 Blobs table? because I feel that it important could separate things like documents and High Res images from thumbnails, because you do not want to sync the High Res Blob table with a thing like a POS system or a tablet.

Would really appreciate some sample code for question 3

I have to say that this is the easiest , most productive database design I have ever seen. I'm a total beginner and did not have to learn a single sql query with the code snippet feature . Thanks Livecloud !!!

Keep safe everyone!
Sid


  Post in Announcements fixed!
Posted by: mark_talluto - 04-10-2020, 06:46 PM - Forum: Announcements - Replies (3)

Hi Everyone. A big shout out to Clarence for pointing out that our Announcement forums were locked and would not all posting replies. This has been fixed. Please feel free to reply to any announcement you like. WhenInSpace has already tested it out with his post this morning. 

We are looking forward to hearing your thoughts.