Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: batch endpoints for column creation and retrieval#206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
darora wants to merge7 commits intomaster
base:master
Choose a base branch
Loading
fromda/columns-batch

Conversation

darora
Copy link
Contributor

existing tests pass

@daroradarora changed the title[wip] feat: batch endpoints for column creation and retrievalfeat: batch endpoints for column creation and retrievalMar 20, 2022
@@ -54,6 +55,26 @@ export default async (fastify: FastifyInstance) => {
return data
})

fastify.get<{
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I've opted to expose these separately rather than have the existing endpoints handle both cases; it gets annoying with the GET accepting a single ID param (and just gnarly in any case).

We can replace the current endpoint as part of a breaking change in the future.

Copy link
ContributorAuthor

@daroradarora left a comment

Choose a reason for hiding this comment

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

Looks good! Couple of minor suggestions

if (!regexp.test(id)) {
return { data: null, error: { message: 'Invalid format for column ID' } }

const invalidId = ids.find((id) => !regexp.test(id))
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Would recommend findAll (or equivalent) here

Copy link
Member

Choose a reason for hiding this comment

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

👍

table,
schema = 'public',
}: {
ids?: string[]
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I really dislike this way of everything being optional - can we use a discriminated union type instead?

Copy link
Member

Choose a reason for hiding this comment

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

It's a TS thing - the 2 function declaration above it means it's eitherids ornames +table +schema

}),
body: Type.Union([postgresColumnCreateSchema, Type.Array(postgresColumnCreateSchema)]),
response: {
200: Type.Union([postgresColumnSchema, Type.Array(postgresColumnSchema)]),
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

If we wanted to be really nice about it, would be cool to pluck the table name out of the array, since we don't allow multiple different values for the field here anyway

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to make the response format consistent:T | T[] for everything

Makes the Array.isArray check at the end always true
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@soedirgosoedirgosoedirgo approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@darora@soedirgo

[8]ページ先頭

©2009-2025 Movatter.jp