Select id as text, not auth

Options
pachocastillosr
pachocastillosr Member
edited August 2023 in ? Help! I'm a Noob

Hi,

I am trying to set id as text. However, Xano automatically takes it as if it was an "auth" value, which it isn't. What can I do for it to stop taking it as auth? I already tried typing "id" into the text box, did not work.


Thanks

Best Answer

Answers

  • arturosanz
    arturosanz Member ✭✭
    edited August 2023
    Options

    "id" is a reserved field name in Xano. All tables have an integer "id" field auto-managed by Xano which you can't delete.

    There is an "id" value under the "auth" section that you can assign to any variable but, again, it's an integer referencing the primary key (id field) of the table you are using for authentication.

  • pachocastillosr
    pachocastillosr Member
    edited August 2023
    Options

    @arturosanz thanks for replying!

    What if I am calling an external api which returns a field "id"? I wouldn't be able to reference it in any way then?

    I need to unset this "id" field from this json:

  • pachocastillosr
    Options

    If this is true that there is no way to reference a field "id" in a json because it is reserved by Xano, this might be something important to fix.

    There are many json objects received by external apis (not in our control) that use that path and it would be terribly obstructive not being able to reference it. @Michael Udinski @Lachlan

    I would appreciate any help, maybe there is a workaround or something I'm not seeing. Thanks!

  • arturosanz
    arturosanz Member ✭✭
    edited August 2023
    Options

    Whatever you get from an external API is saved into a variable in Xano, but a variable is just a temporary space in memory, not a table or field which are meant for permanent storage entities. Each table in Xano has an internal "id" field, but this doesn't affect variables.

    You can use and reference external APIs "id" fields, which aren't true fields, but just elements of an object variable, without limitations. They can be integers, text, or whatever the external API established for them.

    What you shouldn't do is to transfer directly the external API response to your Xano permanent storage (tables) mapping all fields without adapting the "id" key first, if needed.

    For instance, if the external API has an integer "id" in theory you could safely force Xano to save it in the reserved "id" field, probably losing the auto increment feature afterwards.

    However, if the external API has a text "id" instead, you can't save it in Xano's integer id field, but you can add another unique "id_api" text field to the table, index it if you need to, and use it. Your table will have two fields, Xano's "id" which is the primary key, and the external API "id_api".

    Xano needs the internal "id" fields in all tables, which are the primary keys, to establish relationships among tables. Xano decided to use unique integer values starting from 1 for those primary keys. It's the simplest way to understand a primary key for customers too.