#Issue: Tenant not getting selected in Payload's Multi-Tenant Plugin

16 messages · Page 1 of 1 (latest)

wild steeple
#

I'm using Payload's multi-tenant plugin, but the tenant isn't being selected in the following query:

const doc = await payload.findByID({
  collection: 'pages',
  id: "6799c4596610d1f18550b1d7",
  draft: true,
  depth: 2,
  select: {
    id: true,
    slug: true,
    title: true,
  },
  populate: {
    tenants: {
      slug: true,
    },
  },
});

  • Return values include only id, slug and title fields.
  • I have even try adding tenant: true in defaultPopulate

Any pointers will be highly appreciated. Thanks in advance!

civic tendonBOT
wild steeple
#

@calm lichen, you may have an answer. Thanks in advance for your time and help.

flint seal
#

Can you try adding tenants to your select

calm lichen
#

I think it’s tenant singular, yeah?

wild steeple
#

Worked! Thanks to both of you.

#

Getting the id and slug back from tenants collection.

flint seal
#

Glad it worked either way tho

wild steeple
#

Yes, tenant singular worked!

civic tendonBOT
wild steeple
#

Getting this TS error while accessing doc.tenant

Property 'tenant' does not exist on type 'DataFromCollectionSlug<CollectionSlug>'.
  Property 'tenant' does not exist on type 'Search'.
calm lichen
#

You added search as a multi tenant collection?

wild steeple
#

Nah! Only pages

multiTenantPlugin({
  collections: {
    pages: {},
  },
  userHasAccessToAllTenants: () => true,
}),
calm lichen
#

I assume the search type is coming from a collection named search right?

#

I’m confused where the ts error is being thrown from