小编Mar*_*mes的帖子

使用excel.js模块+节点在列标题之前添加行

我正在尝试使用node.js中的excel.js模块创建xslx文件.我能够创建列并添加其值.但是,我需要在列标题之前插入一些行,在那里我可以有一些描述.我怎样才能做到这一点?

我需要这样的东西

任何帮助将不胜感激

我试过的代码是

     var worksheet = workbook.getWorksheet(1);
    worksheet.mergeCells('A1:B1');
    var row = worksheet.getRow(1);
    row.getCell(1).value =' Hello, World!'; 
   // ... merged cells are linked 
    worksheet.getCell('A1').value = 'PI';
    worksheet.columns = [
        {header: 'Id', key: 'id', width: 10},
        {header: 'Name', key: 'name', width: 32},
        {header: 'complexity', key: 'complexity', width: 10},
        {header: 'hours', key: 'hours', width: 10},
        {header: 'cost', key: 'cost', width: 10}
    ];
     worksheet.addRow({name:'m', complexity: 'd', hours:5, cost: 7});
Run Code Online (Sandbox Code Playgroud)

javascript excel node.js exceljs

8
推荐指数
1
解决办法
5304
查看次数

瘦()里面填充了猫鼬

我在mongoose中填充用户集合,并且如果用户使用社交帐户注册,则想要设置标记.所以我在填充中选择那些字段.但出于安全方面的考虑,我不想将其作为回应.所以我使用它将其转换为普通对象lean()并将值设置为null.但是,一旦null为特定用户设置了值,那么它将该值设置为null user_id.如何设置null或如何隐藏响应.

 Pins.find(condition)
   .limit(limit)
   .sort({time: -1})
   .populate({
     path: 'user_id',
     select: '_id name pic twitter_id fb_id',
     options: { lean: true}
   })
   .lean()
   .exec(function(err, data) {

        if(data){
         var flag = 0
            async.eachSeries(data, function(v, callback1) {

              if(v.user_id.twitter_id || v.user_id.fb_id ){
                  v.socialaccount=1
                  v.user_id.fb_id =''
                   v.user_id.twitter_id =''
              }else{
                  v.socialaccount=0 
                      v.user_id.fb_id =''
                   v.user_id.twitter_id =''
              }
             callback1()



     },function(){
              console.log(data)
             callback(data)  

            })

        } else {
            callback(data)
        }

    })
Run Code Online (Sandbox Code Playgroud)

提前致谢

mongoose node.js mongoose-populate

6
推荐指数
1
解决办法
7410
查看次数

Mean.js req.isAuthenticated显示失败?

我已经下载了meanjs version@0.1.12.我已经使用了两个服务器用于前端我hvae使用angular with ionic它在localhost:3000中运行,对于后端我使用了meanjs.in that meanjs我创建了注册,登录和文章.当我使用meansjs作为后端和前端它工作正常.但是当我连接到另一台服务器(localhost:3000)注册并且签名工作正常但是当我创建文章时我得到401未经授权的那个请求的bcoz .isAuthenticated()函数.当我创建文章模块req.isAuthenticated()获取fail.req.isAuthenticated()我不应该通过这个功能我已经包括我的代码任何人帮助我

现在我传递这样的数据

    $http.post('http://192.168.1.14:3000/articles', credentials).success(function(response,data,errorResponse) {
            // If successful we assign the response to the global user model
            //$scope.authentication.user =response;
             console.log(response);

             console.log(data);
            // And redirect to the index page
            $location.path('/tab/account');
        }, function(response,data,errorResponse) {
            $scope.error = errorResponse.data.message;
            console.log($scope.error);
            console.log(data);
        });
Run Code Online (Sandbox Code Playgroud)

路线:

app.route('/articles')
        .get(users.requiresLogin,articles.list)
        .post(users.requiresLogin,articles.create);
Run Code Online (Sandbox Code Playgroud)

登录检查

/**
 * Require login routing middleware
 */
exports.requiresLogin = function(req, res, next) {
    //console.log(req.isAuthenticated());
    console.log(req);
    if (!req.isAuthenticated()) {
        return res.status(401).send({
            message: 'User is not logged in'
        });
    }

    next();
};

/** …
Run Code Online (Sandbox Code Playgroud)

node.js express passport-local meanjs passport.js

6
推荐指数
1
解决办法
218
查看次数

用流星填充mongodb

我正在使用meteor.js.我有三个收集板,类别,用户.

Boards : 
 {
 "_id": ObjectId("su873u498i0900909sd"),
  "locked": NumberInt(0),
 "board_name": "Legends",
  "description": "legends of the world",
   "cat_id":  ObjectId("su873u498i0900909sd"),
  "cost": NumberInt(1),
 "image": "1389249002691_indexhj.jpeg",
"creator": ObjectId("52ce317994acdcee0fadc90c")
}

categories:
{
"_id": ObjectId("su873u498i0900909sd"),
 "user_id": ObjectId("su873u498i0900909sd"),
catname:"hjjj"
 }

users:
{
 "_id":ObjectId(55acec2687fe55f12ded5b4a),
"username" :"mariya"
}
Run Code Online (Sandbox Code Playgroud)

从这里我想获得用户集合中的用户名,该用户集合在类别集合中引用user_id字段,其中类别集合在board集合中使用cat_id引用.这是试图获得它的方式.

 Boards.find({_id:"ObjectId(55acec2687fe55f12ded5b4a)"},function(res){
  if(res){

 categories.find({_id:res.cat_id},function(res1){
   if(res1){
     users.find({_id:res.user_id},function(res3){
      res.send(res3)
     })

   })
 })
Run Code Online (Sandbox Code Playgroud)

由于在流星中使用猫鼬会影响性能我不能使用populate方法.那么有没有其他方法来实现结果而不是一个?

mongodb meteor

4
推荐指数
1
解决办法
1236
查看次数