摘要: 1,连接数据库: cmd 进入终端,输入 mongo 输入 show dbs 可以看到所以的数据库: 刚开始会有这三个数据库 2,创建数据库(加入创建一个 hello 的数据库) 需要 往 hello 数据库的 user 集合中插入一条数据,数据库才真正创建成功 3,插入(增加)数据 db.user 阅读全文
posted @ 2021-02-02 00:28 shanlu 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 1,explain explain 会帮助你获得查询方面诸多有用的信息。只要对游标调用该方法,就可以得到查询细节。explain 会返回一个文档,而不是游标本身 > use hello switched to db hello > db.user.find().explain("executionS 阅读全文
posted @ 2021-02-02 00:26 shanlu 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 1,创建超级管理用户: > show dbs admin 0.000GB config 0.000GB local 0.000GB > use admin switched to db admin > db.createUser({ ... user:"admin", ... pwd:"123", 阅读全文
posted @ 2021-02-02 00:25 shanlu 阅读(68) 评论(0) 推荐(0) 编辑
摘要: fs.stat 检测是文件还是目录 const fs = require('fs') fs.stat('./testdir',(err,data)=>{ if(err){ console.log(err) return } console.log(`是文件:${data.isFile()}`) co 阅读全文
posted @ 2021-02-02 00:24 shanlu 阅读(71) 评论(0) 推荐(0) 编辑
摘要: assets文件夹下面有images css js目录 以及index.html , 找出 wwwroot目录下面的所有的目录,然后放在一个数组中 const fs = require('fs') var path = './assets' var dirArr=[] fs.readdir(path 阅读全文
posted @ 2021-02-02 00:23 shanlu 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 定义一个 add 模块并暴露出去: function add(a,b){ return a+b } exports.add = add; 测试文件中引入这个模块,并调用这个模块中的方法: const util = require('./util/add') console.log(util); // 阅读全文
posted @ 2021-02-02 00:22 shanlu 阅读(142) 评论(0) 推荐(0) 编辑
摘要: url.parse() : 解析 url const url = require('url') const api = "http://www.baidu.com?name=jack&sex=1" const _url=url.parse(api) console.log(_url) 添加 true 阅读全文
posted @ 2021-02-02 00:21 shanlu 阅读(49) 评论(0) 推荐(0) 编辑
摘要: VSCode 中,输入 node-http-server,自动创建一个 web 服务 //node-http-server var http = require('http'); http.createServer(function (request, response) { response.wr 阅读全文
posted @ 2021-02-02 00:19 shanlu 阅读(57) 评论(0) 推荐(0) 编辑
摘要: WEB服务器: 一般指网站服务器,是指驻留在因特网上某种类型计算机的程序,可以向浏览器等Web 客户端提供文档,也可以放置网站文件让全世界浏览,还可以放置数据文件,让全世界下载,目前最主流的Web服务器有 Apache,Nginx,IIS等。 NodeJS 创建一个WEB服务器, 可以让我们访问We 阅读全文
posted @ 2021-02-02 00:18 shanlu 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 路由(Routing)是由一个URI(或者叫路径)和一个特定的HTTP 方法(GET、POST 等)组成的,涉及到应用如何响应客户端对某个网站节点的访问。路由指的就是针对不同请求的URL,处理不同的业务逻辑。 route.js const http = require('http'); const 阅读全文
posted @ 2021-02-02 00:17 shanlu 阅读(66) 评论(0) 推荐(0) 编辑