joas8211/payload-tenancy

How to use with local api (on collections)

silveltman opened this issue · 1 comments

For the new globals feature you added the following explanation in the docs:

To operate on isolated globals using Local API, you must pass user object with a tenant so that the correct document is accessed.

const globalDocument = await payload.findGlobal({
  slug: "settings",
  user: { tenant: someTenantOrId },
});

For regular collection, is adding user: { tenant: someTenantOrId } also the way to go?

I think it should be possible to do that. You can also use where conditions with tenant.equals query. If the request is made by user, just pass the original request object to the call. Remember to set overrideAccess to false if you want to have restricted access.