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

Typescript #38

Open
newtack opened this issue Nov 12, 2018 · 4 comments
Open

Typescript #38

newtack opened this issue Nov 12, 2018 · 4 comments

Comments

@newtack
Copy link

newtack commented Nov 12, 2018

Can you re-implement the library in Typescript, or at a minimum provide modern Typescript API (with support for promises/async/await, good typings, etc.)? The API uses an old-style callback approach and should be using promises instead. While I could wrap it myself (e.g. https://medium.freecodecamp.org/how-to-make-a-promise-out-of-a-callback-function-in-javascript-d8ec35d1f981), I really shouldn't have to do this.

Typescript is awesome and I would have expected that a modern Microsoft product would use it.

@thomaslevesque
Copy link
Contributor

@newtack it's not directly supported, but there's a way to do it anyway. I wrote about it a few months ago:
https://thomaslevesque.com/2019/07/15/using-typescript-to-write-cosmos-db-stored-procedures-with-async-await/

@Oblarg
Copy link

Oblarg commented Jul 14, 2020

The method detailed above is very brittle and has a lot of moving parts. Consider this, instead:

https://github.com/Oblarg/cosmosdb-storedprocs-ts

@thomaslevesque
Copy link
Contributor

@Oblarg very nice!

Yes, I know my approach isn't ideal... I'm not a front-end dev and I don't know much about the JS toolchain, so I was unable to achieve what I wanted using webpack. Your solution is probably more robust. A few remarks:

Modify database.js to include your actual connection string, database name, and container names.

This is a bit annoying... Any chance it could be packaged in a way that doesn't involve modifying the code? I assume database.js is only used for deployment, right? Maybe it could just be done by passing arguments to the npm task?

Also, I think it would make sense to split build-storedprocs into 2 separate steps:

  • build
  • deploy

Because one might want to build without deploying immediately, e.g. in a CI process.

Also, it looks like there is no support for user-defined functions or triggers.

Anyway, this is a nice step in the right direction!

@chriskuech
Copy link

The Azure Portal interface for writing stored procs has autocomplete enabled yet the library does not containing typings to hit the autocompleter. This results in a poor and confusing experience. Adding typings would considerably increase developer confidence when writing stored procs as they would have immediate confirmation whether their code will run without integration issues, and would allow developers to remain in the editor rather than having to constantly view documentation.

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

4 participants