我想在数据库中上传一些统计信息,如何从回调中取出一些内容并将其放入变量中以简化此操作?

码:

csgo.requestPlayersProfile(account_id, function(ranking) {
                console.log(ranking);
            });


结果(排名):

Got handled GC message PlayersProfile
{ my_current_event_teams: [],
  my_current_event_stages: [],
  account_id: xxxxxxx,
  ongoingmatch: null,
  global_stats: null,
  penalty_seconds: null,
  penalty_reason: null,
  vac_banned: null,
  ranking:
   { account_id: xxxxxxx,
     rank_id: 16,
     wins: 1081,
     rank_change: null },
  commendation: { cmd_friendly: 23, cmd_teaching: 24, cmd_leader: 24 },
  medals:
   { display_items_defidx:
      [ 969, 4551, 1377, 970, 1358, 4354, 1340, 1338, 1331, 1329, 1030, 874 ],
     medal_team: null,
     medal_combat: null,
     medal_weapon: null,
     medal_global: null,
     medal_arms: null,
     featured_display_item_defidx: 969 },
  my_current_event: null,
  my_current_team: null,
  survey_vote: null,
  activity: null,
  player_level: 19,
  player_cur_xp: 327682724,
  player_xp_bonus_flags: null }


因此,作为示例,我想将rank_id: 16放入变量(例如var rank = 16;)中,这样我就不能只使用"UPDATE Users SET Rank='rank'"

最佳答案

var rank = ranking.ranking.rank_id;

关于javascript - 如何“查找并插入”变量?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59899635/

10-16 20:59