Back

ID.unique() not working for me!

  • 0
  • Databases
  • General
  • Self Hosted
ianmont
13 Mar, 2023, 20:54

Hi this may sound super stupid or maybe im doing it wrong cause im kinda new but this doesnt work from me:

import { ID } from 'appwrite';

async function rentarCasaOnetime() { console.log(ID.unique()) }

The console.log returns:

unique() like if it was a string or something but it doesnt execute the function

it returns without the autogen id what is happening?

TL;DR
Title: ID.unique() not working; use UUID instead - User mentions that ID.unique() function is not working for them. - Another user suggests using the npm package 'uuid' to generate UUIDs instead. - User asks if it is possible to return a string from the client side. - User shares a link to the code that creates random IDs using the Utopia PHP framework. - Another user clarifies that the ID generation happens on the server side, not the client side. - User shares their code using ID.unique() and mentions that it returns 'unique()' as a string. - User asks for assistance, as the
Binyamin
13 Mar, 2023, 21:42

I also wonder about it, but actually the function just returns a string and the AppWrite engine creating the ID on the machine and not on your end

Binyamin
13 Mar, 2023, 21:46

The actual functions that creates the random ID is part of the Utopia PHP framework which is maintained also by AppWrite,

You can see the code here https://github.com/utopia-php/database/blob/main/src/Database/Helpers/ID.php

ianmont
14 Mar, 2023, 01:28

thanks, and is there any way i could return a string from the client side?

VincentGe
14 Mar, 2023, 15:41

You can just generate a UUID using any of the JS client libraries

VincentGe
14 Mar, 2023, 15:41
ianmont
14 Mar, 2023, 16:43

alright thanks !

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more