This message was deleted.
# community-help
s
This message was deleted.
m
Copy code
const collectionExists = async (client: Client, schema: CollectionCreateSchema) => {
  try {
    await client.collections(schema.name).retrieve()
    return true
  } catch (e) {
    if ((e as TypesenseError).httpStatus === 404) {
      return false
    } else {
      throw e
    }
  }
}
how else can I update my schema when there are breaking changes?
j
If you're running a HA cluster, this might be due to eventual consistency. For eg, if the delete request is executed by one node and hasn't yet been executed by all nodes in the cluster, and in the meantime a create request makes it way to a different node, that will throw an error. I'd recommend giving a few second between deleting and trying to recreate a collection with the same name.
To answer your second question, you can either do an in-place change (only recommended in non-production envs since it is a blocking operation): https://typesense.org/docs/0.25.1/api/collections.html#modifying-an-existing-field or use an alias: https://typesense.org/docs/0.25.1/api/collections.html#using-an-alias
m
i tried automating modifying existing fields and it was a nightmare
i'm okay with deleting and recreating the schema but i don't really see how to do that on a HA cluster in an automated fashion. waiting a few seconds wasn't giving good results
j
Using an alias will let you do a zero downtime switch from an old collection to a new collection: https://typesense.org/docs/0.25.1/api/collections.html#using-an-alias