丁同亚的博客
夺朱非正色
05 2021 档案
vue生命周期详解
摘要:![](https://img2020.cnblogs.com/blog/2232092/202105/2232092-20210528095308853-894336722.png) 阅读全文
posted @ 2021-05-28 09:47 丁同亚的博客 阅读(52) 评论(0) 推荐(0)
博客系统之验证用户名和密码
摘要:返回Promise,成功则返回用户信息 const login = function (userModel,condition) { const rtn = new Promise((reslove, reject) => { userModel.find(condition, (err, docs 阅读全文
posted @ 2021-05-27 18:55 丁同亚的博客 阅读(82) 评论(0) 推荐(0)
mongoose之模块化使用
摘要:目录结构 module db.js user.ja app.js db.js const mongoose = require('mongoose') mongoose.connect('mongodb://localhost/eg', { useNewUrlParser: true, useUni 阅读全文
posted @ 2021-05-27 18:41 丁同亚的博客 阅读(128) 评论(0) 推荐(0)
mongoose纲要和模型(schema&model)
摘要:根据纲要(Schema)和dataBase中的集合(Collection)创建模型(Model) Schema(纲要):并没有实质性的操作集合,只是在程序中设定了一些规则,然后应用规则到数据库集合中来创建model. const userSchema= new mongoose.Schema({ / 阅读全文
posted @ 2021-05-24 10:24 丁同亚的博客 阅读(246) 评论(0) 推荐(0)
mongoose连接数据库(connect函数)
摘要:数据库的连接 const mongoose = require('mongoose') // 如果数据库(database)不存在就会创建 mongoose.connect('mongodb://localhost/eg', { useNewUrlParser: true, useUnifiedTo 阅读全文
posted @ 2021-05-23 19:30 丁同亚的博客 阅读(2051) 评论(0) 推荐(0)
async和await
摘要:async和await是解决异步编程问题的。 promise的then方法链式调用不够优雅 async 修饰的函数同步返回一个promise 使用await必须包裹一个async修饰的函数 async返回的promise的状态由await修饰的promise的状态决定 如果await修饰的promi 阅读全文
posted @ 2021-05-18 16:13 丁同亚的博客 阅读(89) 评论(0) 推荐(0)
package.json&package-lock.json(项目描述文件)
摘要:package.json项目描述文件,记录了当前项目信息,例如项目名称、版本、作者、github地址、当前项目依赖了哪些第三方模块等。 使用npm init-y命令生成。 记录了依赖模块,项目名称,版本号,程序入口,开发时依赖,简写命令等 { "dependencies": { "bluebird" 阅读全文
posted @ 2021-05-16 18:54 丁同亚的博客 阅读(92) 评论(0) 推荐(0)
node第三方模块
摘要:nodemon nodemon app.js 源码更改就重新运行 nrm nrm ls nrm use *** 更改npm下载地址 gulp 构建工具 阅读全文
posted @ 2021-05-16 18:34 丁同亚的博客 阅读(34) 评论(0) 推荐(0)
node核心模块promise化
摘要:先安装 bluebird npm install bluebird 使用promisifyAll函数,可以将模块导出的接口promise化,注意处理后的API函数名加Async如:fs.readFileAsync() var Promise = require('bluebird') const f 阅读全文
posted @ 2021-05-16 14:01 丁同亚的博客 阅读(98) 评论(0) 推荐(0)
node模块化之模块导出导入
摘要://此时是等价的 exports.name = 'xxx' module.exports.sex = '男' //此时把module.export指向的对象改变,以module.exports为准 module.exports = { id:'1', girlfriend:{ name:'yyy' 阅读全文
posted @ 2021-05-16 10:05 丁同亚的博客 阅读(144) 评论(0) 推荐(0)