视频演示
https://www.bilibili.com/video/BV1BT4y1E7Nh/?p=9
我们一起来完成以下步骤:
-
使用之前工程的代码
-
创建数据库脚本
-
创建数据库连接
-
新增员工model
-
创建员工仓库类repositories
-
创建员工services类
-
添加增删查改代码
#controllers/employeeController.ts
import { Context } from "https://deno.land/x/oak/mod.ts";
import { Employee } from "../models/employee.ts";
import employeeService from "../services/employeeService.ts";
const { cwd } = Deno;
class Controller {
static async hello(ctx: any){
//cwd获取当前工程目录
//注意 ' !== `
ctx.render(`${cwd()}/views/index.ejs`,{
title:"Testing",
data:{nam