当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Meteor.users.findOne方法代码示例

本文整理汇总了TypeScript中meteor/meteor.Meteor.users.findOne方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Meteor.users.findOne方法的具体用法?TypeScript Meteor.users.findOne怎么用?TypeScript Meteor.users.findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meteor/meteor.Meteor.users的用法示例。


在下文中一共展示了Meteor.users.findOne方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

  invite: function (partyId:string, userId:string) {
    check(partyId, String);
    check(userId, String);
 
    let party = Parties.findOne(partyId);
 
    if (!party)
      throw new Meteor.Error('404', 'No such party!');
 
    if (party.public)
      throw new Meteor.Error('400', 'That party is public. No need to invite people.');
 
    if (party.owner !== this.userId)
      throw new Meteor.Error('403', 'No permissions!');
 
    if (userId !== party.owner && (party.invited || []).indexOf(userId) == -1) {
      Parties.update(partyId, {$addToSet: {invited: userId}});
 
      let from = getContactEmail(Meteor.users.findOne(this.userId));
      let to = getContactEmail(Meteor.users.findOne(userId));
 
      if (Meteor.isServer && to) {
        Email.send({
          from: 'noreply@socially.com',
          to: to,
          replyTo: from || undefined,
          subject: 'PARTY: ' + party.name,
          text: `Hi, I just invited you to ${party.name} on Socially.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}\n`
        });
      }
    }
  },
开发者ID:ElijahWolfe,项目名称:socially,代码行数:33,代码来源:methods.ts

示例2: function

  invite: function (trackId:string, userId:string) {
    check(trackId, String);
    check(userId, String);

    let track = Tracks.collection.findOne(trackId);

    if (!track)
      throw new Meteor.Error('404', 'No such track!');

    if (track.public)
      throw new Meteor.Error('400', 'That track is public. No need to invite people.');

    if (track.owner !== this.userId)
      throw new Meteor.Error('403', 'No permissions!');

    if (userId !== track.owner && (track.invited || []).indexOf(userId) == -1) {
      Tracks.collection.update(trackId, {$addToSet: {invited: userId}});

      let from = getContactEmail(Meteor.users.findOne(this.userId));
      let to = getContactEmail(Meteor.users.findOne(userId));

      if (Meteor.isServer && to) {
        Email.send({
          from: 'noreply@beetrut.com',
          to: to,
          replyTo: from || undefined,
          subject: 'TRACK: ' + track.name,
          text: `Hi, I just invited you to ${track.name} on Beetrut.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}\n`
        });
      }
    }
  },
开发者ID:harishmaiya,项目名称:gundmi48-gadikatte58,代码行数:33,代码来源:tracks.methods.ts

示例3: sendPost

  sendPost(p) {
    let name = Meteor.users.findOne(Meteor.userId()).profile.name;
    Meteor.call('simpanPost', {
      idUser: Meteor.userId(),
      name: name,
      status: p,
      dateTime: new Date(),
      comments: [],
      likes: []
    }, (error) => {
      if (error) {
        console.log(error);
      }
      this.inputPost = '';

      Meteor.call('simpanTimeLine', {
        dateTime: new Date(),
        status: 'post',
        message: `${name} send post '${p}'`
      }, (error) => {
        if (error) {
          console.log(error);
        }
      });
    });
  }
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:26,代码来源:post-component.ts

示例4: sendComment

  sendComment(c) {

    let name = Meteor.users.findOne(Meteor.userId()).profile.name;

    this.comments.push({
      idUser: Meteor.userId(),
      name: name,
      comment: c
    });

    Posts.update(
      {
        _id: this.idPost
      }, {
        $set: {
          comments: this.comments
        }
      }
    );

    Meteor.call('simpanTimeLine', {
      dateTime: new Date(),
      status: 'comment',
      message: `${name} commented on ${this.nameUserPost}'s post`
    }, (error) => {
      if (error) {
        console.log(error);
      }
    });

    this.inputComment = '';
  }
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:32,代码来源:post-component.ts

示例5: function

  setCustomSystem: function(name) {
    name = name.trim().toLowerCase();
    let character = Characters.findOne({
      uid: this.userId
    });
    if (character == null) {
      throw new Meteor.Error('error', 'The server does not know about your character.');
    }
    if (!((character.roles != null) && character.roles.indexOf('admin') >= 0)) {
      throw new Meteor.Error('error', 'You are not authorized to perform this action.');
    }
    let user = Meteor.users.findOne({_id: this.userId});
    if (!user) {
      throw new Meteor.Error('error', 'The server does not know about your character.');
    }
    let fsys = SolarSystems.findOne({name_lower: name});
    if (!fsys) {
      throw new Meteor.Error('error', 'Cannot find the requested system.');
    }

    return Settings.update({
      _id: 'incursion'
    }, {
      $set: {
        sysid: parseInt(fsys._id, 10),
        sysname: fsys.name,
      }
    });
  },
开发者ID:paralin,项目名称:evewaitlist,代码行数:29,代码来源:methodsb.ts

示例6: getEmail

export function getEmail(self) {
    try {
        return Meteor.users.findOne(self.userId).services.google.email;
    } catch (e) {
        return null;
    }
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例7: getUser

function getUser(): {username: String, userId: String} {
    if (this.userId) {
        return Meteor.users.findOne({_id: this.userId})
    } else {
        return Meteor.user();
    }
}
开发者ID:Puzochacha,项目名称:rhy,代码行数:7,代码来源:game.ts

示例8: invite

export function invite(partyId, userId) {
  check(partyId, String);
  check(userId, String);

  if (!this.userId) {
    throw new Meteor.Error(400, 'You have to be logged in!');
  }

  const party = Parties.findOne(partyId);

  if (!party) {
    throw new Meteor.Error(404, 'No such party!');
  }

  if (party.owner !== this.userId) {
    throw new Meteor.Error(404, 'No permissions!');
  }

  if (party.public) {
    throw new Meteor.Error(400, 'That party is public. No need to invite people.');
  }

  if (userId !== party.owner && ! _.contains(party.invited, userId)) {
    Parties.update(partyId, {
      $addToSet: {
        invited: userId
      }
    });

    const replyTo = getContactEmail(Meteor.users.findOne(this.userId));
    const to = getContactEmail(Meteor.users.findOne(userId));

    if (Meteor.isServer && to) {
      Email.send({
        to,
        replyTo,
        from: 'noreply@socially.com',
        subject: `PARTY: ${party.title}`,
        text: `
          Hey, I just invited you to ${party.title} on Socially.
          Come check it out: ${Meteor.absoluteUrl()}
        `
      });
    }
  }
}
开发者ID:AyushAnandChouksey,项目名称:meteor-angular-socially,代码行数:46,代码来源:methods.ts

示例9: getUser

export function getUser(userId?: string) {
    if(Boolean(userId)) {
        return Meteor.users.findOne({
            _id: userId
        });
    } else if (Meteor.user()) {
        return Meteor.user();
    } else {
        return null;
    }
}
开发者ID:Puzochacha,项目名称:rhy,代码行数:11,代码来源:user.ts

示例10: sendLike

  sendLike(idPost, l, n) {
    let checkUser: Boolean;
    let idUser = Meteor.userId();

    if (l.length === 0) {
      checkUser = false;
    } else {
      for (let i = 0; i < l.length; i++) {
        checkUser = idUser === _.property('idUser')(l[i]);
        if (checkUser === true) {
          break;
        }
      }
    }

    let name = Meteor.users.findOne(Meteor.userId()).profile.name;

    if (checkUser === false) {
      l.push({
        idUser: idUser,
        name: name,
      });

      Meteor.call('simpanTimeLine', {
        dateTime: new Date(),
        status: 'like',
        message: `${name} likes ${n}'s post`
      }, (error) => {
        if (error) {
          console.log(error);
        }
      });

    } else {
      l = _.without(l, _.findWhere(l, {
        idUser: Meteor.userId(),
        name: name,
      }));
    }

    Posts.update(
      {
        _id: idPost
      }, {
        $set: {
          likes: l
        }
      }
    );

  }
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:51,代码来源:post-component.ts


注:本文中的meteor/meteor.Meteor.users.findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。