The Ultimate Guide to Typescript with Mongoose for Node.js

preview_player
Показать описание

0:00 Introduction
1:15 What are we going to build?
2:37 Current project setup
5:08 Add types to the Mongoose model
8:40 Add types to the service layer
10:57 Create tests
16:25 Conclusion

In this video, we take a deep dive into typing Mongoose models with TypeScript and using Mongoose's types to make strongly typed services.

Suggested reading:

📚 Concepts & technologies covered
- Mongoose
- TypeScript
- MongoDB

🌎 Follow me here:
Рекомендации по теме
Комментарии
Автор

i am waiting another series of typescript with express

AZ-vusb
Автор

Hi Tom from TomDoesTech, thank you for the video Tom from TomDoesTech

rism
Автор

Thank you very much for this tutorial !!!

HerrThomasE
Автор

The official Mongoose docs say that it's not recommended to extend the mongoose.Document class in a TS interface because it apparently causes some problems with type inferences. You were using it though. What's your opinion on that?

Creamworks
Автор

14:58 I don't really understand why the return from query is not typed? const user = await findUser(....) ?

knful
Автор

At 9:07 you assign the UserDocument type to the CreateQuery generic but in your GitHub repo it has the UserInput type (which makes more sense because that's the purpose for the UserInput type). Is that a mistake?

Creamworks
Автор

not sure if u'll answer this, and please note im new to it, so jsut asking, wouldn't RTK Query be a better solution for services?

vladyslavfereira
Автор

How'd you get auto suggestions [10:03] in the terminal?

--Arthur
Автор

Hi Tom,

I was wondering how would you implement the services using the latest version of mongoose (6.0.14). I cant figure out what to use as parameter type for the CRUD functions, if I try to use for example the UserDocument. it will require additional 46 properties. should I just create another type to for the parameter?

BeatXFire
Автор

Namespace '"mongoose"' has no exported member 'CreateQuery'

Theb-iu
Автор

Awesome!
I've been setting up a multitenant api with the same setup. I've got it working but this should help clean up a lot of the bloat.
There's next to no videos on the topic let alone with types as well. Anyone know someone who could make a video on the topic? I would definitely<like>

Scetils
Автор

but when the model has a reference to another model, how should we write the custom interface?

jhonatanvargas
Автор

Excellent video Thanks, maybe TS Mongo and Graphql with express?

enriquecordero
Автор

I installed the same package versions as the video from the repo but for some reason the options param type for ".findUser" function in the service layer is working with "QueryOptions" instead of "QueryFindBaseOptions". TS gets really upset with the latter despite it still being in the package.


If anyone has any idea how to fix this, it would be appreciated.

Thanks for the videos by the way, highly appreciated

ugurdev
Автор

It should be noted that defining interfaces which extend Document is NOT recommended.

jackiepuppet_
Автор

Hi, this video a help me so much, but i try get data from two models one reference and other with populate, but dont work in typescript, read documentation is different that javascript, u have any idea how do that this or example or video ... T-T

KuRoiBatusai
Автор

This is how you write real code.. i am questioning everything i did lol

aleemahmed
Автор

Hi, where is the watch (MongoDB change stream) functionality? `ModelName.watch(/* ... */)`

kasir-barati
Автор

" extend Document" will be deprecated soon. Better not to use this.

chologhuribangladesh
Автор

good video. 'ULTIMATE GUIDE!!!' ? no. you didn't even use references to another collection in any way and i can think of a ton of stuff i would have included in an ultimate guide to using mongoose with typescript.

aeronwolfe
welcome to shbcf.ru