liuxing / node-abc Goto Github PK
View Code? Open in Web Editor NEW《Node.js入门教程》
《Node.js入门教程》
这个地方:
readStream.on('data', function(chunk) {
progress += chunk.length;
})
只计算了长度,没有写入的代码,最终复制出来的都是空文件。
感觉是不是在上面的回调函数里加上writeStream.write(chunk);
console.log("get data:",data.toString("utf-8"));
如题
我用作者的代码连接了MongoDB数据库的时候,报错出了“Cannot read property 'on' of undefined” 错误,发现是connection.on监听连接成功或失败的回调时出错了,懵逼ing........查了一下,别人是这样写的,
const mongoose = require('mongoose')
const Schema = mongoose.Schema
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://127.0.0.1:27017/books'); //先连接的
// var db = mongoose.connect('mongodb://127.0.0.1:27017/books');
var db = mongoose.connection;
db.on("error", function (error) {
console.log("数据库连接失败:" + error)
})
db.on("open", function () {
console.log("数据库连接成功")
})
这样才连接成功,作为一个初学者,难道是作者的写法已经是过时的写法吗?为啥作者写法会报错的,求大神给我解惑,谢谢大佬!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.