Skip to content

Update findOne method to use new document structure#2950

Merged
pwizla merged 3 commits intostrapi:mainfrom
Bellian:patch-1
Feb 16, 2026
Merged

Update findOne method to use new document structure#2950
pwizla merged 3 commits intostrapi:mainfrom
Bellian:patch-1

Conversation

@Bellian
Copy link
Contributor

@Bellian Bellian commented Feb 16, 2026

Description

I messed arround with this for way too long now.
the documentation is just wrong it seems...

Without the as any I get the following type errors:

Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
  Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
    Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
      Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
        The types returned by 'findOne(...)' are incompatible between these types.
          Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
            Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
              Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
                Types of property 'id' are incompatible.
                  Type 'ID' is not assignable to type 'number'.
                    Type 'string' is not assignable to type 'number'.ts(2345)

Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:

export type AnyDocument = {
    documentId: string;
    id: number;
} & {
    [key: string]: any;
};

Which should be:

export type AnyDocument = {
    documentId: string;
    id: number | string;
} & {
    [key: string]: any;
};

Also this.getFetchParams does not exist if you do not also modify the method.. so you need to access this from the super object.

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request or contribution idea suggested by the Docs team.

I messed arround with this for way too long now.
the documentation is just wrong it seems...

Without the `as any` I get the following type errors:
```
Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
  Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
    Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
      Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
        The types returned by 'findOne(...)' are incompatible between these types.
          Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
            Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
              Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
                Types of property 'id' are incompatible.
                  Type 'ID' is not assignable to type 'number'.
                    Type 'string' is not assignable to type 'number'.ts(2345)
```

Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
```
export type AnyDocument = {
    documentId: string;
    id: number;
} & {
    [key: string]: any;
};
```
Which should be:
```
export type AnyDocument = {
    documentId: string;
    id: number | string;
} & {
    [key: string]: any;
};
```
@strapi-cla
Copy link

strapi-cla commented Feb 16, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ pwizla
❌ Bellian
You have signed the CLA already but the status is still pending? Let us recheck it.

@vercel
Copy link

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
documentation Ready Ready Preview, Comment Feb 16, 2026 10:17am

Request Review

Copy link
Collaborator

@pwizla pwizla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Bellian!

There was a small typo (probably a copy/paste error) + I added comments for super.

The PR is now approved, merged, should be live on docs.strapi.io in a few minutes, and will be mentioned in the next weekly snapshot release.

@pwizla pwizla self-assigned this Feb 16, 2026
@pwizla pwizla added contribution PRs that are part of the Documentation Contribution Program pr: chore source: CMS labels Feb 16, 2026
@pwizla pwizla added this to the 6.16.1 milestone Feb 16, 2026
@pwizla pwizla merged commit d04d2f2 into strapi:main Feb 16, 2026
2 of 3 checks passed
pwizla added a commit that referenced this pull request Feb 16, 2026
* Update findOne method to use new document structure

I messed arround with this for way too long now.
the documentation is just wrong it seems...

Without the `as any` I get the following type errors:
```
Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
  Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
    Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
      Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
        The types returned by 'findOne(...)' are incompatible between these types.
          Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
            Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
              Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
                Types of property 'id' are incompatible.
                  Type 'ID' is not assignable to type 'number'.
                    Type 'string' is not assignable to type 'number'.ts(2345)
```

Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
```
export type AnyDocument = {
    documentId: string;
    id: number;
} & {
    [key: string]: any;
};
```
Which should be:
```
export type AnyDocument = {
    documentId: string;
    id: number | string;
} & {
    [key: string]: any;
};
```

* Apply suggestion from @pwizla

* Apply suggestion from @pwizla

---------

Co-authored-by: Pierre Wizla <pwizla+github@gmail.com>
pwizla added a commit that referenced this pull request Feb 16, 2026
* Update findOne method to use new document structure

I messed arround with this for way too long now.
the documentation is just wrong it seems...

Without the `as any` I get the following type errors:
```
Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
  Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
    Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
      Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
        The types returned by 'findOne(...)' are incompatible between these types.
          Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
            Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
              Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
                Types of property 'id' are incompatible.
                  Type 'ID' is not assignable to type 'number'.
                    Type 'string' is not assignable to type 'number'.ts(2345)
```

Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
```
export type AnyDocument = {
    documentId: string;
    id: number;
} & {
    [key: string]: any;
};
```
Which should be:
```
export type AnyDocument = {
    documentId: string;
    id: number | string;
} & {
    [key: string]: any;
};
```

* Apply suggestion from @pwizla

* Apply suggestion from @pwizla

---------

Co-authored-by: Bellian <cv.jsobotta@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution PRs that are part of the Documentation Contribution Program pr: chore source: CMS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants