Misho
TypeScript
import { Client, Databases, ID } from "appwrite";
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
const databases = new Databases(client);
const promise = databases.createDocument(
'<DATABASE_ID>',
'<COLLECTION_ID>',
ID.unique(),
{ "title": "Hamlet" }
);
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
Is that ID.unique()
thing really unique because i call this on server? for example waht if two users same time calling function that creates some doc based on that
TL;DR
- Developers are questioning the uniqueness of `ID.unique()` when creating a document on the server
- Slim chance of collision, no seen instances
- No issues even if two users call the function simultaneously Steven
It's a very slim chance there will be a collision. I've never seen one
Misho
Okay, thanks
Recommended threads
- Issue with relations on database
I'm creating a food ordering website for businesses. I'm having issues with the relations on my database I attached the attributes for the collections I'm hav...
- The current user is not authorized to pe...
I want to create a document associated with user after log in with OAuth. The user were logged in, but Appwrite said user is unauthorized. User is logged in wi...
- self-hosted auth: /v1/account 404 on saf...
Project created in React/Next.js, Appwrite version 1.6.0. Authentication works in all browsers except Safari (ios), where an attempt to connect to {endpoint}/v1...