10 2016 档案

摘要:由于想在mongoose中使用Q,所以将mongoose升级到了4.1.0,而线上mongoDB的版本是2.6.7,升级的时候,node-modules存在mongoose的残渣,所以调用 npm i 的时候,mongoose没有更新完全, 因此线上就报了 BSON.BSONPure is not 阅读全文
posted @ 2016-10-25 17:21 jay- 阅读(370) 评论(0) 推荐(0) 编辑
摘要:1.如果是基本类型,则是按值传递 var str = 'one';function f(string) { string = 'two';}f(str);console.log(str); // 仍为one, 未受string = 'two'赋值所影响 2.如果是引用类型,则是按共享传递 call 阅读全文
posted @ 2016-10-23 23:23 jay- 阅读(1234) 评论(0) 推荐(0) 编辑
摘要:mapReduce是大数据的核心内容,但实际操作中别用这个,所谓的mapReduce分两步 1.map:将数据分别取出,Map函数调用emit(key,value)遍历集合中所有的记录,将key与value传给Reduce函数进行处理 2.reduce:负责数据的最后处理,function(key, 阅读全文
posted @ 2016-10-23 20:50 jay- 阅读(248) 评论(0) 推荐(0) 编辑
摘要:1. 当应用程序启动时,Mongoose会自动为模式中的每个定义的索引调用ensureIndex。 虽然很好用于开发,但建议在生产中禁用此行为,因为索引创建可能会导致显着的性能影响。 通过将模式的autoIndex选项设置为false来禁用该行为。 Mongoose文档广泛地建议在生产中禁用auto 阅读全文
posted @ 2016-10-23 19:41 jay- 阅读(327) 评论(0) 推荐(0) 编辑
摘要:1.mongodb的聚合是有专门的一个方法的。 阅读全文
posted @ 2016-10-23 16:55 jay- 阅读(123) 评论(0) 推荐(0) 编辑
摘要:1.查询时,不写条件的查询,速度要远远大于有条件的查询。 2.消除重复数据: 3.db.listCommands() 查看mongo的runCommand支持哪些功能了。 db.runCommand() 里面的参数还不一样,runCommand是非常底层的写法。 3.1db.runCommand({ 阅读全文
posted @ 2016-10-23 15:49 jay- 阅读(201) 评论(0) 推荐(0) 编辑
摘要:配置File Transport winston.add(winston.transports.File, options) The File transport should really be the 'Stream' transport since it will accept any Wri 阅读全文
posted @ 2016-10-20 14:15 jay- 阅读(439) 评论(0) 推荐(0) 编辑
摘要:Further Reading 延伸阅读 Events and Callbacks in Winston winston的事件和回调 Each instance of winston.Logger is also an instance of an EventEmitter. A log event 阅读全文
posted @ 2016-10-20 14:05 jay- 阅读(1358) 评论(0) 推荐(0) 编辑
摘要:上次讲到 Exceptions 例外 Handling Uncaught Exceptions with winston 使用winston处理未捕获的异常(这个如果对于异步,我不是很喜欢用) 使用winston,可以从进程捕获和记录uncaughtException事件。 有两种不同的方式通过默认 阅读全文
posted @ 2016-10-20 10:16 jay- 阅读(2388) 评论(0) 推荐(0) 编辑
摘要:Usage There are two different ways to use winston: directly via the default logger, or by instantiating your own Logger. The former is merely intended 阅读全文
posted @ 2016-10-19 18:39 jay- 阅读(3555) 评论(0) 推荐(0) 编辑
摘要:Object 对象 1._.merge(object, [sources]) 此方法类似于_.assign,除了它递归地将源对象的自有和继承的可枚举字符串键控属性合并到目标对象中。 如果存在目标值,将跳过解析为undefined的源属性。 数组和纯对象属性以递归方式合并。 其他对象和值类型将通过赋值 阅读全文
posted @ 2016-10-13 10:50 jay- 阅读(1891) 评论(0) 推荐(0) 编辑
摘要:虽然es6已经出现一段时间了,但是对于没有使用es6的node.js的时候,仍要解决回调金字塔,因此Q还是很有必要的. 阅读全文
posted @ 2016-10-12 18:12 jay- 阅读(316) 评论(0) 推荐(0) 编辑