Strongly-typed database access with Node.JS and TypeScript
问题 When we use C# , we can access our database in a strongly-typed manner using Code-First approach: public class Blog { public int BlogId { get; set; } public string Name { get; set; } public virtual List<Post> Posts { get; set; } } ... public class Database : DbContext { public DbSet<Blog> Blogs { get; set; } public DbSet<Post> Posts { get; set; } } var db = new Database() var blog = new Blog { Name = "My new blog", BlogId = 1 }; db.Blogs.Add(blog); db.SaveChanges(); // save object to database