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

Option to create a new Object #114

Open
zimbres opened this issue Mar 14, 2024 · 4 comments
Open

Option to create a new Object #114

zimbres opened this issue Mar 14, 2024 · 4 comments

Comments

@zimbres
Copy link

zimbres commented Mar 14, 2024

Is there an option to create a new object? Thanks!

@ttu
Copy link
Owner

ttu commented Mar 15, 2024

Hi! Yes, you can post any data you, with any name (example has abcd) and it will be stored to JSON-file and can be fetched with the name you defined.

# Add new data
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{ "value": "1", "description": "hello", "random": "data" }' http://localhost:57602/api/abcd/

# Fetch created data
curl http://localhost:57602/api/abcd/0

If you have any other questions, just let me know 👍

@zimbres
Copy link
Author

zimbres commented Mar 15, 2024

Hi, in this case, this will create an array inside the object abcd, I what I mean is to create for example:

  "abcd": {
      "value": "1",
      "description": "hello",
      "random": "data",
      "id": 0
    }

@ttu
Copy link
Owner

ttu commented Mar 15, 2024

Sorry, misunderstood the question.

Change Api.UpsertOnPut to true from config:

Replace/Add new object with PUT:

# Add new data
curl -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{ "value": "1", "description": "hello", "random": "data" }' http://localhost:57602/api/abcd/

# Fetch created data
curl http://localhost:57602/api/abcd

Apparently there is nothing about objects it in the docs, besides the route list 🤔

PUT      /api/{object}
PATCH    /api/{object}
DELETE   /api/{object}

Thanks for the question. I wouldn't have noticed this without it!

@zimbres
Copy link
Author

zimbres commented Mar 16, 2024

Awesome! Thanks a lot!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants