Collection update


I am trying to cross-reference collections: I can’t include a dataType to a collection that doesn’t exist which I understand but in the following scenario I want to be able crossrefence eachother

const schema = {
  "classes": [
      "class": "Author",
      "properties": [
          "name": "name",
          "dataType": ["string"]
          "name": "books",
          "dataType": ["Book"],
          "cardinality": "many"
      "class": "Book",
      "properties": [
          "name": "title",
          "dataType": ["string"]
          "name": "authors",
          "dataType": ["Author"],
          "cardinality": "many"

How can I do this (weaviate javascript) or can I create the collection and then update the collection after all collections are created with the properties needed to crossreference?

Server Setup Information

  • Weaviate Server Version: weaviate-client-ts 2.1.0
  • Deployment Method: NA
  • Multi Node? Number of Running Nodes:
  • Client Language and Version: Typescript (weaviate-client.ts 2.10)

Any additional Information

const classWithSharding = async (
    className: string,
    properties: any = [],
    vectorizer: string = "text2vec-openai",
    distance: string = "cosine"
  ) => {
    const classWithSharding = {
      class: className,
      vectorizer: vectorizer,
      vectorIndexConfig: {
        distance: distance,
      properties: [],
      shardingConfig: {
        virtualPerPhysical: 128,
        desiredCount: 1,
        actualCount: 1,
        desiredVirtualCount: 128,
        actualVirtualCount: 128,

    if (properties) = properties

    // Add the class to the schema
    let result = await weaviateApp.schema

    // The returned value is the full class definition, showing all defaults
    console.log(JSON.stringify(result, null, 2))
    return result

hi @Standerpm!

Welcome to our community :hugs:

On that case, you will need to add for example the book collection first, then you can add the Author collection (now creating the cross reference already) and finally adding the reference from book to author.

Here is an example in python using the v4 client:

import weaviate
from weaviate import classes as wvc
client = weaviate.connect_to_local()

client.collections.delete(["Book", "Author"])

book = client.collections.create(
        wvc.config.Property(name="Title", data_type=wvc.config.DataType.TEXT),
    #references=[wvc.config.ReferenceProperty(name="has_author", target_collection="Author")]

author = client.collections.create(
    properties=[wvc.config.Property(name="Name", data_type=wvc.config.DataType.TEXT)],
    references=[wvc.config.ReferenceProperty(name="has_book", target_collection="Book")]

    wvc.config.ReferenceProperty(name="has_author", target_collection="Author")

here is how you can do it also with JS/TS:

Please, let me know if this helps!


1 Like

Hi @DudaNogueira, I just wanted to quickly ask whether there is also a method to delete a cross reference from a collection (I mean not the data, but the conceptual possibility that it has a cross reference). And is it possible to get the collections referencing to the current collection?

Many thanks!

hi @c-lara !!

You can remove only the cross reference, here is the doc:

Regard getting the collections that reference one particular collection, you will need to list all collections, inspect their references.

For example, this will list one reference field:


let me know if this is what you are looking for.


1 Like

Hi @DudaNogueira,

Many thanks, that helps a lot! Just one follow-up: The removal means removing an actual cross-reference of an object but not the “hasReference” attribute from the collection definition right? I was actually looking for something like this, but it seems to me that once properties and references are defined for a collection, one cannot remove them anymore?

That’s right.

AFAIK, the removal of a property is not yet supported: