Udate Key Name


I want to update key name which included in data for multi documents from shell.
Is that possible?

data: { currencyRef: …}

data: { currencyTypeRef: …}

Thank you.

There’s no single command to update the key name, because there isn’t (yet) a defined, enforced schema. Each document could have its own associated keys.

However, you could Map/Paginate over all of the documents in your collection updating the key with a Let/Update statement setting the existing currencyRef key to null. This removes the field from the document.

In a query, this would look something like:

        currencyRef: Select(["data", "currencyRef"], Get(Var("docRef")))
          data: {
            currencyTypeRef: Var("currencyRef"),
            currencyRef: null

You’ll need to handle pagination based on the number of documents in your collection.

Be sure to consider impact on your indexes. You may also feel more comfortable mapping through adding the new field in one transaction, checking that everything is correct, and then removing the old key currencyRef in a second transaction.

1 Like

I got the solution you suggested, I was thinking of something similar to this but was wondering if there is a single FQL command.
Thank you very much.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.