# Collection update

**URL:** <https://forum.weaviate.io/t/collection-update/1724>\
**Category:** Support\
**Created:** [March 15, 2024, 8:16am UTC](https://forum.weaviate.io/t/collection-update/1724 "2024-03-15T08:16:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Standerpm](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@Standerpm](https://forum.weaviate.io/u/Standerpm)\
**Post date:** [March 15, 2024, 8:16am UTC](https://forum.weaviate.io/t/collection-update/1724/1 "2024-03-15T08:16:06Z")

</div>

### Description

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

```auto
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

```auto
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) classWithSharding.properties = properties

    // Add the class to the schema
    let result = await weaviateApp.schema
      .classCreator()
      .withClass(classWithSharding)
      .do()

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

```

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [March 15, 2024, 9:46pm UTC](https://forum.weaviate.io/t/collection-update/1724/2 "2024-03-15T21:46:41Z")

</div>

hi @Standerpm!

Welcome to our community 🤗

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:

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

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

book = client.collections.create(
    name="Book",
    properties=[
        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(
    name="Author",
    properties=[wvc.config.Property(name="Name", data_type=wvc.config.DataType.TEXT)],
    references=[wvc.config.ReferenceProperty(name="has_book", target_collection="Book")]
)

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

```

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

> **[Cross-references | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/manage-data/cross-references#add-a-cross-reference-property)**
>
> Use cross-references to establish directional relationships between collections.

Please, let me know if this helps!

Thanks!

---

<div class="post-metadata">

**Author:** ![c-lara](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/c-lara/32/560_2.png) [@c-lara](https://forum.weaviate.io/u/c-lara)\
**Post date:** [April 22, 2024, 3:51pm UTC](https://forum.weaviate.io/t/collection-update/1724/3 "2024-04-22T15:51:35Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [April 22, 2024, 5:34pm UTC](https://forum.weaviate.io/t/collection-update/1724/4 "2024-04-22T17:34:07Z")

</div>

hi @c-lara !!

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

> **[Cross-references | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/manage-data/cross-references#delete-a-cross-reference)**
>
> Use cross-references to establish directional relationships between collections.

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:

```auto
book.config.get().references[0].target_collections

```

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

Thanks!

---

<div class="post-metadata">

**Author:** ![c-lara](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/c-lara/32/560_2.png) [@c-lara](https://forum.weaviate.io/u/c-lara)\
**Post date:** [April 23, 2024, 9:16am UTC](https://forum.weaviate.io/t/collection-update/1724/5 "2024-04-23T09:16:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [April 26, 2024, 1:30pm UTC](https://forum.weaviate.io/t/collection-update/1724/6 "2024-04-26T13:30:19Z")

</div>

That’s right.

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

> **[Update objects | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/manage-data/update#delete-a-property)**
>
> Weaviate allows partial or complete object updates.
