• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create & Update (field types)
#1
Looking at the Batch update, I see this code:

## Update Jenny's record
put "47" into tDataA[tClientsTableID]["87654321-abcd-1234-cdef-1234567890ab"]["age"]
put "110000" into tDataA[tClientsTableID]["87654321-abcd-1234-cdef-1234567890ab"]["income"]

It looks like that long UUID references Jenny's account. Which would be available after the user logs in.
But what's that reference to tClientsTableID? Could it be the table where "age" and "income" are stored?
Maybe. But you wouldn't name a table "tClientsTableID". So I'm probably wrong.

Question: If I have a record with many fields, does the whole record get written over or just the field or fields I'm updating? 

Question: Does this mean fields don't have an intrinsic type and store everything as a string? (or text) Numbers too?
  Reply
#2
Hi Paul,

I am excited you are moving along fast!

A little bit background about LiveCloud. Everything is referenced by UUID. Projects, tables, and records all have its own UUID as a reference.

You are correct that the long UUID is referencing Jenny's record and the tClientsTableID is referencing the table where Jenny's record is being stored.

The reason why the example is using tClientsTableID is because we put the UUID of the table into tClientsTableID so it is easier for us to reuse it.
In the example, we are trying to show how a LiveCloud user can get access to the tableID easily.

Quote:# Table name: clients                       
# Keys: firstName, lastName, age, income    

# Records: 

# [87654321-abcd-1234-cdef-1234567890ab]["firstName"] - "Jenny"
# [87654321-abcd-1234-cdef-1234567890ab]["lastName"] - "Smith"
# [87654321-abcd-1234-cdef-1234567890ab]["age"] - "46"
# [87654321-abcd-1234-cdef-1234567890ab]["income"] - "100000" 
Above is the schema of the table and what Jenny's record looks like internally. It is an array with the key being the UUID. The next layers are all the keys of Jenny that has value populated.

Quote:put cdb_tableID("clients") into tClientsTableID   
Above is where in the code example that we put the UUID of the table into tClientsTableID


Quote:Question: If I have a record with many fields, does the whole record get written over or just the field or fields I'm updating? 
Only the fields you are updating will get overwritten.
If you call an update with the below array, Jenny's age will be set to 47; Jenny's income will be set to empty; Jenny's first name and last name will remain untouched.

put "47" into tDataA[tClientsTableID]["87654321-abcd-1234-cdef-1234567890ab"]["age"]
put "" into tDataA[tClientsTableID]["87654321-abcd-1234-cdef-1234567890ab"]["income"]

If there are data being updated by different sources, you can look at merge.


Quote:Question: Does this mean fields don't have an intrinsic type and store everything as a string? (or text) Numbers too?
Correct, there is no typing in LiveCloud, we just store them as string. However, there is hyperblobs that you can store binary data like images.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)