NestJS + Mongo + Typegoose

The current state of Mongo with NestJS ( and Node) .Currently you have 3 options to use Mongo with Node (and NestJS).1) NestJS + Mongoose where maybe the best tutorial I have found is here https://scotch.io/tutorials/building-a-modern-app-using-nestjs-mongodb-and-vuejs the issue is that I hate the fact I had to write the schema definitions and the typescript interfaces. If you are fine with writing everything 2 times ones the Schema and ones the Document as Typescript Interface maybe this is the best way to go.2) NestJS + TypeORM where you can actually use TypeORM with MongoDB, however I do not recomment this if you want to learn more I would ask you to write this blog post https://medium.com/articode/typeorm-mongodb-review-8855903228b13) NestJS + Typegoose - basically what it does is it uses your domain objects to get the schema from them. And this is what this post is all about. There is a lot of documentation how you can achieve that, however I didn't like most of it, it just looked like too much code. On top of that ALL tutorials ALWAYS include using of a DTO class and I don't see a reason to use DTO classes at all in 99% of the cases.DTOs are great because of many reasons, but none of the tutorials on the internet actually explains why they want DTOs and in fact none of them need DTOs so I would like to write the most easy straightforward NEST + MongoDB + TypeGoose example.So first of all we will install nestjs cli, NestJS is very, very similar to Angular and even if you dont like angular trust me you will like NestJS. Great beginners tutorial for NestJS you can read...

JavaScript inheritance (object-oriented programming)

  There are many posts explaining what JavaScript inheritance is how it works, is it bad or good, how it is comparable with Java inheritance with millions of examples using third party apis or function to make inheritance look more like C#/C++/Java Inheritance. This post is just to show HOW inheritance looks without anything else except browser so next time when you need to find it you can open this post which explains everything you need. JavaScript uses so called prototype inheritance you don’t need to know more except it is different then a C#/C++/Java way of doing inheritance Define a class In JavaScript you can define class like this: function A(){     this.aMethod = function (){         alert("A method");     }     this.bMethod = function () {         alert( "B Method");     } } Yes, yes there are different ways I find this one the most easy one  you can read more about the ways how to create a class in JavaScript here : http://www.phpied.com/3-ways-to-define-a-javascript-class/ Next you have a class how can you use it ? var a = new A(); a.bMethod(); //will print B method a.aMethod(); //will print A method BAM nothing else, easy right? ok so what if you want to extend this class ? Prototype Inheritance First you will create another class: function B(){     this.cMethod = function () {         alert("C method");     } } ok but how can I say that B extends A ? Simple : B.prototype = new A(); Example : B.prototype = new A(); var b = new B(); b.aMethod(); //will print A method b.bMethod(); //will print B method b.cMethod();...

JavaScript inheritance (object-oriented programming)

  There are many posts explaining what JavaScript inheritance is how it works, is it bad or good, how it is comparable with Java inheritance with millions of examples using third party apis or function to make inheritance look more like C#/C++/Java Inheritance. This post is just to show HOW inheritance looks without anything else except browser so next time when you need to find it you can open this post which explains everything you need. JavaScript uses so called prototype inheritance you don’t need to know more except it is different then a C#/C++/Java way of doing inheritance Define a class In JavaScript you can define class like this: function A(){     this.aMethod = function (){         alert("A method");     }     this.bMethod = function () {         alert( "B Method");     } } Yes, yes there are different ways I find this one the most easy one  you can read more about the ways how to create a class in JavaScript here : http://www.phpied.com/3-ways-to-define-a-javascript-class/ Next you have a class how can you use it ? var a = new A(); a.bMethod(); //will print B method a.aMethod(); //will print A method BAM nothing else, easy right? ok so what if you want to extend this class ? Prototype Inheritance First you will create another class: function B(){     this.cMethod = function () {         alert("C method");     } } ok but how can I say that B extends A ? Simple : B.prototype = new A(); Example : B.prototype = new A(); var b = new B(); b.aMethod(); //will print A method b.bMethod(); //will print B method b.cMethod();...

JavaScript inheritance (object-oriented programming)

  There are many posts explaining what JavaScript inheritance is how it works, is it bad or good, how it is comparable with Java inheritance with millions of examples using third party apis or function to make inheritance look more like C#/C++/Java Inheritance. This post is just to show HOW inheritance looks without anything else except browser so next time when you need to find it you can open this post which explains everything you need. JavaScript uses so called prototype inheritance you don’t need to know more except it is different then a C#/C++/Java way of doing inheritance Define a class In JavaScript you can define class like this: function A(){     this.aMethod = function (){         alert("A method");     }     this.bMethod = function () {         alert( "B Method");     } } Yes, yes there are different ways I find this one the most easy one  you can read more about the ways how to create a class in JavaScript here : http://www.phpied.com/3-ways-to-define-a-javascript-class/ Next you have a class how can you use it ? var a = new A(); a.bMethod(); //will print B method a.aMethod(); //will print A method BAM nothing else, easy right? ok so what if you want to extend this class ? Prototype Inheritance First you will create another class: function B(){     this.cMethod = function () {         alert("C method");     } } ok but how can I say that B extends A ? Simple : B.prototype = new A(); Example : B.prototype = new A(); var b = new B(); b.aMethod(); //will print A method b.bMethod(); //will print B method b.cMethod();...