Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query hook for any API method #53

Merged
merged 11 commits into from
Jun 25, 2020
Merged

Add query hook for any API method #53

merged 11 commits into from
Jun 25, 2020

Conversation

Aschen
Copy link
Contributor

@Aschen Aschen commented Jun 22, 2020

What does this PR do?

When no command is found, Kourou will try to execute the given command with the sdk:query command.

The first argument has to be the name of the controller and the action separated by a semicolon (eg document:create)

Kourou will try to infer common arguments like index, collection, _id or body.

It will automatically infer and accept the following lists of arguments:

  • <command> <index>

    • eg: kourou collection:list iot
      .
  • <command> <index> <collection>

    • eg: kourou collection:truncate iot sensors
      .
  • <command> <index> <collection> <body>

    • eg: kourou bulk:import iot sensors '{bulkData: []}'
      .
  • <command> <index> <collection> <id>

    • eg: kourou document:delete iot sensors sigfox-123
      .
  • <command> <index> <collection> <id> <body>

    • eg: kourou document:create iot sensors sigfox-123 '{temperature: 42}'

Then any argument will be passed as-is to the sdk:query method.

Other changes

  • add --id argument to sdk:query
  • remove document:get
  • remove document:create

src/commands/collection/create.ts Outdated Show resolved Hide resolved
Co-authored-by: Leonardo D'Aubeterre <bluedraggy@gmail.com>
...kuzzleFlags
}

static args = [
{ name: 'index', description: 'Index name', required: true },
{ name: 'collection', description: 'Collection name', required: true }
{ name: 'collection', description: 'Collection name', required: true },
{ name: 'body', description: 'Collection mappings and settings in JS or JSON format. Will be read from STDIN if available' },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ name: 'body', description: 'Collection mappings and settings in JS or JSON format. Will be read from STDIN if available' },
{ name: 'body', description: 'Collection mappings and settings in JS or JSON format. Will be read from STDIN if available' }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is intended, it's so much easier when you end with a trailing comma to add new element or copy paste any element

@Aschen Aschen merged commit 7e87476 into develop Jun 25, 2020
@Aschen Aschen deleted the add-query-hook branch June 25, 2020 02:40
@Aschen Aschen mentioned this pull request Jul 16, 2020
Aschen added a commit that referenced this pull request Jul 16, 2020
# [0.14.0](https://github.com/kuzzleio/kourou/releases/tag/0.14.0) (2020-07-16)


#### New features

- [ [#55](#55) ] User mapping import export   ([berthieresteban](https://github.com/berthieresteban))
- [ [#54](#54) ] Instance:list and instance:kill commands   ([berthieresteban](https://github.com/berthieresteban))
- [ [#53](#53) ] Add query hook for any API method   ([Aschen](https://github.com/Aschen))
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants