# deleteMany is not working as expected when multi tenancy is enabled JavaScript client ( v3.8.0)

**URL:** <https://forum.weaviate.io/t/deletemany-is-not-working-as-expected-when-multi-tenancy-is-enabled-javascript-client-v3-8-0/21720>\
**Category:** Support\
**Tags:** bug, developer-experience, javascript, technical\
**Created:** [July 25, 2025, 6:35am UTC](https://forum.weaviate.io/t/deletemany-is-not-working-as-expected-when-multi-tenancy-is-enabled-javascript-client-v3-8-0/21720 "2025-07-25T06:35:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhil1728](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/nikhil1728/32/4246_2.png) [@nikhil1728](https://forum.weaviate.io/u/nikhil1728)\
**Post date:** [July 25, 2025, 6:35am UTC](https://forum.weaviate.io/t/deletemany-is-not-working-as-expected-when-multi-tenancy-is-enabled-javascript-client-v3-8-0/21720/1 "2025-07-25T06:35:04Z")

</div>

Context:  
I’m using the `weaviate-client` (v3.8.0) for JavaScriptand trying to perform a `deleteMany` operation in a multi-tenant collection using the documented `tenant` option.

Code That Fails:

```js
const response = await collection.data.deleteMany(
  collection.filter.byProperty('docId').containsAny(docIds),
  {
    tenant: tenantName
  }
);

```

Error:  
The client throws an error that no tenant was specified, even though it was provided in the argument.

Investigation:  
Looking into the client source code at:  
`weaviate-client/dist/node/cjs/collections/data/index.js`

The relevant code is:

```js
deleteMany: (where, opts) =>
  connection
    .batch(name, consistencyLevel, tenant) // tenant is undefined here
    .then((batch) =>
      batch.withDelete({
        filters: Serialize.filtersGRPC(where),
        dryRun: opts?.dryRun,
        verbose: opts?.verbose,
      })
    )

```

The issue is that `tenant` is being passed to `connection.batch(...)`, but it’s never assigned from `opts`. So even if I provide `opts.tenant`, it doesn’t get used.

Expected Fix:  
The code should extract the tenant from the options like this:

```js
const tenant = opts?.tenant;

```

or

```js
.batch(name, consistencyLevel, opts?.tenant)

```

Please confirm if this is a known issue, or if I’m using the API incorrectly. Happy to provide more details or help test a fix.

---

<div class="post-metadata">

**Author:** ![malgamves](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/malgamves/32/5970_2.png) [@malgamves](https://forum.weaviate.io/u/malgamves)\
**Post date:** [July 25, 2025, 10:08am UTC](https://forum.weaviate.io/t/deletemany-is-not-working-as-expected-when-multi-tenancy-is-enabled-javascript-client-v3-8-0/21720/2 "2025-07-25T10:08:10Z")

</div>

Hey @nikhil1728, thanks for flagging this. Could you try and use the client as [documented here](https://docs.weaviate.io/weaviate/manage-collections/multi-tenancy#crud-operations)?

If the issue persists could you open an issue on the [client repo](https://github.com/weaviate/typescript-client/issues)?

---

<div class="post-metadata">

**Author:** ![nikhil1728](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/nikhil1728/32/4246_2.png) [@nikhil1728](https://forum.weaviate.io/u/nikhil1728)\
**Post date:** [July 25, 2025, 2:45pm UTC](https://forum.weaviate.io/t/deletemany-is-not-working-as-expected-when-multi-tenancy-is-enabled-javascript-client-v3-8-0/21720/3 "2025-07-25T14:45:44Z")

</div>

Hi @malgamves thanks! It works as follows:

```js
const collection = client.collections.get(indexName);
const tenant = collection.withTenant(tenantName);
const response = await tenant.data.deleteMany(
  tenant.filter.byProperty('docId').containsAny(docIds)
);

```
