小编Sar*_*maz的帖子

MongoDB一次查询多个集合

users
{
 "_id":"12345",
 "admin":1
},
{
 "_id":"123456789",
 "admin":0
}

posts
{
 "content":"Some content",
 "owner_id":"12345",
 "via":"facebook"
},
{
 "content":"Some other content",
 "owner_id":"123456789",
 "via":"facebook"
}
Run Code Online (Sandbox Code Playgroud)

这是我的mongodb的样本.我想获得所有帖子的"via"属性等于"facebook"并由admin发布("admin":1).我无法弄清楚如何获取此查询.由于mongodb不是关系数据库,我无法进行连接操作.可能是什么解决方案?

collections join mongodb

64
推荐指数
4
解决办法
12万
查看次数

使用 jQuery 动画回到原始位置

我想要将用户单击的图像动画化到左上角 100x100,然后我希望它返回到动画开始的原始位置,但是使用这段代码,它会不断向顶部和左侧滑动一些像素。我无法弄清楚是什么原因导致了这个问题。怎样才能让它回到原来的位置呢?

var posLeft;
var posTop;

$(this).children("img").click(function() {


        goToTopLeft($(this));

        $.each($(this).parent().children("img"), function() {

            $(this).css("z-index","0");

        });

        goToFrontFromTopLeft($(this));

        $(this).css("z-index", "1");



    });

function goToTopLeft(img) {
        posLeft = img.position().left;
        posTop = img.position().top;
        img.animate({ top: '-=100', left: '-=100', height: 'toggle' }, 500);
    }

    function goToFrontFromTopLeft(img) {
        img.animate({ top: posTop, left: posLeft, height: 'toggle' }, 500);
    }
Run Code Online (Sandbox Code Playgroud)

jquery positioning jquery-animate

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