Is there a way for me to modify the record Id
I already have a database and they have their records Id already. It's a UUID similar to the ones you are using but slightly different.
If I create new records that are not a problem (as these ids are alpha so it does not matter as long as they are unique).
But if I want to use existing records it's another problem.
I can definitively ignore your ids but I think it's a bit of waste.
However, if I can change an id or provide the id when I create a new record it will be OK.
Please let me know...
Best,
Hi Phil,
You are most welcome. Thank you for taking the time to learn CanelaDB and LiveCloud. I am sure you will become a master in no time. You are well on your way. I try to be in the forums every day to answer questions.
Hi Phil,
We generate our UUIDs using put uuid() into tRecordID.
Thus, no need to supply any arguments for the uuid() function. CanelaDB validates custom recordIDs for every API call. Thus, using this model will keep you compatible.
-Mark
02-23-2022, 10:26 AM
(This post was last modified: 02-23-2022, 02:05 PM by philippecoenen.)
Hey Mark,
Thank you so much for all your answers.
Ok so I have created an array to create a record using: put uuid() into aObject["cdbRecordID"]
But when I attempt to create the record on the could database I get this error: Illegal key name starting with either 'cdb' or 'csi'
as you confirm that you are using uuid() and I do the same I guess it's not the uuid itself that is the problem.
I know I can get the id when the record is created but it will make my life a little more complicated for some operations.
What can I do?
-Phil
02-24-2022, 01:10 PM
(This post was last modified: 02-24-2022, 01:12 PM by stamatis.)
I don't think you can generate a cdbRecordID at will - although Mark will confirm.
I've had a similar scenario where i had existing primary/foreign keys in UUID format. I solved it by creating new foreign key for each record that corresponds to the correct cdbRecordID.
1. create columns for primary/foreign keys in all tables affected; these store your existing keys (while of course each record has the liveCloud derived cdbRecordID)
2. for each foreign key, i set up a function to return the cdbRecordID of the record that contains the correct primaryKey in the new primary key column
3. I then replace or store in a new column a new foreign key that corresponds
4. The final result is that all foreign keys now point to the correct cdbRecordID as primary key, and i no longer need the old primary/foreign keys.
hope that helps (or even makes sense!)
Stam
02-25-2022, 10:21 AM
(This post was last modified: 02-26-2022, 07:53 AM by philippecoenen.)
Hey Stamatis,
Mark says it's possible to force the uuid. (Check his answers upper)
He may argue that only the batch "batchCreate" can do that as he proposes in his answer.
I was trying to do the trick using the "create" instead.
So I will try with the batch create it might be the problem.
Thanks for your answer anyway.
-Phil