const tagModel = require("../mongodb");

 1 const mongoose = require("mongoose");
2 mongoose.connect("mongodb://127.0.0.1:27017/Test")
3 const tagSchema = new mongoose.Schema({
4 text: {
5 type: String,
6 minlength: 2,
7 maxlength: 12
8 }
9 })
10 const tagModel = new mongoose.model("tag", tagSchema);
11
12 module.exports = tagModel;


1 module.exports = function (router) {
2 router.get("/tag", async (ctx) => {
3 // const arr = [{ text: "HTML" }, { text: "SQL" }, { text: "nodejs" },]
4 // tagModel.insertMany(arr, function (err, docs) {
5 // console.log(err);
6 // console.log(docs);
7 // });
8
9 //查询
10 const data = await tagModel.find({});
11
12 ctx.body = {
13 status: 200,
14 data: data,
15 msg: ""
16 }
17 })
18 }

最新文章

  1. 领域驱动和MVVM应用于UWP开发的一些思考
  2. VS快速生成JSON数据格式对应的实体
  3. JavaScript UI选型及Jquery EasyUI使用经验谈
  4. js-JavaScript高级程序设计学习笔记17
  5. 对弈类游戏的人工智能(5)--2048游戏AI的解读
  6. Linux下各个目录的作用
  7. 一、HTML和CSS基础--HTML+CSS基础课程--第3部分
  8. Design Patterns---- Strategy 模式
  9. Window 2008 R2 + IIS7.5 + VS2013 错误代码 0x80070002
  10. HDOJ-1041 Computer Transformation(找规律+大数运算)
  11. Jquery学习笔记:获取jquery对象的基本方法
  12. 如何用C#使用java
  13. HDU - 1907 John 反Nimm博弈
  14. jquery实现ajax提交表单的方法总结
  15. Python中的鸡肋多线程
  16. elasticsearch 使用快照进行备份
  17. AndroidStudio 开发JNI
  18. browse-agent type and curl post
  19. C++中 explicit的用法
  20. java.lang.String cannot be cast to java.util.Date

热门文章

  1. 1888: 生成括号(等级考试3级 2021-09 T5)
  2. 计算机网络12 TCP
  3. mysql19-锁
  4. 服务调用OpenFeign
  5. 消息传递(news)题解
  6. windows server backup 无法使用或wbadmin.msc致命错误解决方法
  7. JS 获取参数、封装
  8. Canvas:绘制多边形
  9. PostgreSQL建立索引时,如何避免写数据锁定
  10. pytorch 衣服等