小编Emi*_*ska的帖子

获取后,将新属性添加到Mongoose Document

我在理解JavaScript中的变量操作时遇到了问题.以下代码:

UserScore.find(filter, function (err, userScores) {
  var contests = [];
  userScores.forEach(function(userScore)
  {
    contests.push(userScore.ContestId);
  });
  Contest.find({ '_id': { $in : contests } }, function(err, contestItems)
  {
    var result = [];

    contestItems.forEach(function(con)
    {
      userScores.forEach(function(element) {
        if(element.ContestId == con._id)
        {
          con.UserTeamName = element.TeamName;
          con.UserPersonalScore = element.Score;
          console.log(con);
          console.log(con.UserPersonalScore);
          result.push(con);
          return;
        }
      });
    });
    res.status(200).json(result);
  });
});
Run Code Online (Sandbox Code Playgroud)

在没有添加两个属性的情况下打印"con",并使用适当的值打印"con.UserPersonalScore".当推送到结果时,con没有其他属性.我错过了什么?

我想我在某种程度上创建局部变量而不是属性,但为什么不将它推送到结果数组?

javascript mongoose mongodb

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

如何在XAML中将图像剪切为椭圆

在本文中:https://msdn.microsoft.com/en-us/library/windows/apps/jj206957%28v=vs.105%29.aspx显示了一种将图像剪切为椭圆的方法,但是当我复制到我的项目我得到一个错误,我不能使用椭圆几何,因为期望的类型是"RectangleGeometry".我正在构建一个Windows Phone 8应用程序.

这篇文章有问题还是我错过了什么?

我的xaml代码示例:

<Border BorderThickness="1" BorderBrush="AliceBlue">
        <Grid Margin="{StaticResource GridMargin}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="2*"></ColumnDefinition>
                <ColumnDefinition Width="1.5*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Image Grid.Column="0" Stretch="Uniform" Source="{Binding Photo}">
                <Image.Clip>
                    <EllipseGeometry RadiusX="100" RadiusY="100" Center="225,175"/>
                </Image.Clip>
            </Image>
            <Grid Grid.Column="1" Margin="{StaticResource SmallGridMargin}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="1.5*"></RowDefinition>
                    <RowDefinition Height="2*"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                </Grid.RowDefinitions>
                <Viewbox Stretch="Uniform" Grid.Row="0">
                    <TextBlock Text="{Binding BookAuthor}"></TextBlock>
                </Viewbox>
                <Viewbox Stretch="Uniform" Grid.Row="1">
                    <TextBlock Text="{Binding BookTitle}"></TextBlock>
                </Viewbox>
                <Viewbox Stretch="Uniform" Grid.Row="2">
                    <TextBlock Text="{Binding Id}"></TextBlock>
                </Viewbox>
            </Grid>
Run Code Online (Sandbox Code Playgroud)

c# xaml windows-phone-8

2
推荐指数
1
解决办法
3414
查看次数

标签 统计

c# ×1

javascript ×1

mongodb ×1

mongoose ×1

windows-phone-8 ×1

xaml ×1