How to use the leanengine.Query function in leanengine

To help you get started, we’ve selected a few leanengine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DesertsP / Valine-Admin / cloud.js View on Github external
let ip = currentComment.get('ip') || defaultIp;
    console.log('IP: %s', ip);
    spam.checkSpam(currentComment, ip);

    // AT评论通知
    let rid =currentComment.get('pid') || currentComment.get('rid');

    if (!rid) {
        console.log("这条评论没有 @ 任何人");
        return;
    } else if (currentComment.get('isSpam')) {
        console.log('评论未通过审核,通知邮件暂不发送');
        return;
    }

    let query = new AV.Query('Comment');
    query.get(rid).then(function (parentComment) {
        if (parentComment.get('mail') && parentComment.get('mail') !== process.env.BLOGGER_EMAIL) {
            mail.send(currentComment, parentComment);
        } else {
            console.log('被@者匿名,不会发送通知');
        }
        
    }, function (error) {
        console.warn('获取@对象失败!');
    });
}
github DesertsP / Valine-Admin / routes / comments.js View on Github external
router.get('/mark-spam', function (req, res, next) {
    if (req.currentUser) {
        let query = new AV.Query(Comment);
        query.get(req.query.id).then(function (object) {
            object.set('isSpam', true);
            object.set('ACL', {"*":{"read":false}} );
            object.save();
            spam.submitSpam(object);
            res.redirect('/comments')
        }, function (err) {
        }).catch(next);
    } else {
        res.redirect('/');
    }
});
github brucx / mp-push-leancloud / models.js View on Github external
async findChannels () {
    let userToChannelQuery = new AV.Query('UserToChannel')
    let results = await userToChannelQuery.equalTo('user', this.Object).find()
    return results.map(userToChannel => {
      return userToChannel.get('channelName')
    })
  }
github leancloud / leanengine-nodejs-demos / functions / batch-update.js View on Github external
const createQuery = () => {
    return new AV.Query(Post)
  }
github leancloud / leanengine-nodejs-demos / functions / associated-data.js View on Github external
AV.Cloud.define('getPostWithAuthor', async request => {
  const post = await new AV.Query(Post).get(request.params.id)
  const user = await fetchUserFromCache(post.get('author').id)

  return _.extend(post.toJSON(), {
    author: user
  })
})
github huanz / surge-hosts / surge.js View on Github external
exports.update = function (params, cb) {
    if ((Date.now() - params.time) < 60 * 60 * 1000) {
        return cb('更新频率过高');
    }
    var query = new AV.Query('Token');
    query.first().then(function(res) {
        var GHTOKEN = res.get('token');
        var cmds = [];
        try {
            var stat = fs.statSync('surge-hosts');
            if (stat.isDirectory()) {
                cmds = [
                    'cd hosts && git pull',
                    'cd surge-hosts && git pull',
                    'cd ipv6-hosts && git pull'
                ];
            } else {
                cmds = [
                    'rm -rf hosts surge-hosts ipv6-hosts',
                    'git clone --depth 1 --branch master --single-branch https://github.com/googlehosts/hosts.git',
                    'git clone --depth 1 --branch master --single-branch https://github.com/lennylxx/ipv6-hosts.git',
github jiangjiu / vue-leancloud-blog / server-modules / content.js View on Github external
const queryArticle = (id) => {
    const query = new AV.Query('ContentList')
    return query.get(id)
  }
github jiangjiu / vue-leancloud-blog / server-modules / tags.js View on Github external
const queryTags = () => {
    const query = new AV.Query('Tags')
    return query.find()
  }