• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function: AddKeys (clarification)
#2
(04-26-2019, 05:52 PM)Paul Wrote: This is the example from documentation: https://docs.livecloud.io/AddKeys/ 

Quote:local tTable, tKeys

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

put "clients" into tTable
put "occupation,address" into tKeys

cdb_addKeys tTable,tKeys 

It looks like the table, Clients, already has fields, occupation and address, and this command is initializing them as keys. Is this correct?
I'm a little confused by the comment, # Keys: firstName, lastName, age, income. Does that imply these were previously set as keys?

Hi Paul,

Let's start with the example you quoted. The comments imply that we are starting with a table named "clients" that contains the keys "firstName", "lastName", "age", and "income". The "clients" table does not contain the "occupation" and "address" keys yet.

The cdb_addKeys command adds keys "occupation" and "address" to the "clients" table. After calling cdb_addKeys, as shown in the example, the "clients" table will contains the keys "firstName", "lastName", "age", "income", "occupation", and "address".


   


Quote:When defining keys in this way, field values are sorted as text. Correct?

Can you elaborate? I'm not sure if I'm understanding your question correctly. The image above is a screenshot of a table in LiveCloud Manager (LCM). The first row displays the keys of the table. Subsequent rows are records. Both keys of a table and values of a record are stored as text. Records viewed in LCM can be sorted by any key of the table. Records will be sorted by the text in the value of the chosen key. Hope this helps. Please let me know if I didn't answer your question. 



Quote:Are numeric keys currently supported?

Yes, numeric table keys are supported. Table keys can be alphanumeric. The same goes for key values. Additionally, key values can also be LiveCode arrays.
  Reply


Messages In This Thread
Function: AddKeys (clarification) - by Paul - 04-26-2019, 05:52 PM
RE: Function: AddKeys (clarification) - by efrain.c - 04-26-2019, 07:23 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)