Dart 后台开发 Aqueduct 插入数据 获取数据API

import 'package:aqueduct/aqueduct.dart';
import 'package:demo2/model/model.dart';

class UserController extends ResourceController {
  UserController(this.context);
  ManagedContext context;

  @Operation.get()
  Future getAllUser() async {
    final query = Query(context);
    final allUser = await query.fetch();
    return Response.ok(allUser);
  }

  @Operation.post()
  Future insertUser(@Bind.body() Model model) async {
    final query = Query(context);
    query.values = model;
    final user = await query.insert();
    return Response.ok(user);
  }
}

视频教程查看以下链接
https://www.bilibili.com/video/BV1C54y1Y7Lm

你可能感兴趣的:(Dart 后台开发 Aqueduct 插入数据 获取数据API)