music.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // 导入BoleMbti脚本
  2. // 引用Parse JS SDK
  3. const Parse = require("parse/node");
  4. Parse.initialize("dev"); // 设置applicationId
  5. Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL
  6. let music= [
  7. { "name": "偏爱", "image": "assets/image/BoFan.png", "author": "张芸京", "rating": 8.5 },
  8. { "name": "雪之华", "image": "assets/image/BoFan.png", "author": "中岛美嘉", "rating": 9.3 },
  9. { "name": "是你", "image": "assets/image/BoFan.png", "author": "梦然", "rating": 9.0 },
  10. { "name": "悬溺", "image": "assets/image/BoFan.png", "author": "葛东琪", "rating": 8.7 },
  11. { "name": "雾里", "image": "assets/image/BoFan.png", "author": "朵芊", "rating": 9.3 },
  12. { "name": "祈愿~致那个时候的你~", "image": "assets/image/BoFan.png", "author": "当山真玲", "rating": 9.1 },
  13. { "name": "SAKURA", "image": "assets/image/BoFan.png", "author": "Che·Nelle", "rating": 9.2 },
  14. { "name": "Letting Go", "image": "assets/image/BoFan.png", "author": "蔡建雅", "rating": 9.4 },
  15. { "name": "我们啊", "image": "assets/image/BoFan.png", "author": "三块木头", "rating": 9.5 },
  16. { "name": "星辰不坠落", "image": "assets/image/BoFan.png", "author": "蓝心羽", "rating": 9.6 },
  17. { "name": "溯", "image": "assets/image/BoFan.png", "author": "马吟吟", "rating": 9.1 },
  18. { "name": "你啊你啊", "image": "assets/image/BoFan.png", "author": "魏如宣", "rating": 9.0 },
  19. { "name": "Tattoo", "image": "assets/image/BoFan.png", "author": "GJan", "rating": 9.3 }
  20. ];
  21. function importAll(){
  22. let LQLMusic= []
  23. Object.keys(music).forEach(key=>{
  24. LQLMusic.push({
  25. // result:key,
  26. name:music[key]?.name,
  27. author:music[key]?.author,
  28. rating:music[key]?.rating,
  29. image:music[key]?.image,
  30. })
  31. })
  32. console.log(LQLMusic)
  33. LQLMusic.forEach(async mbti => {
  34. // 查重
  35. let exists = await checkExists(mbti)
  36. if(exists?.id) return;
  37. // 新增
  38. let LQLMusic = Parse.Object.extend("LQLMusic");
  39. let bm = new LQLMusic();
  40. bm.set(mbti);
  41. bm.save();
  42. });
  43. }
  44. async function checkExists(mbti){
  45. let query = new Parse.Query("LQLMusic");
  46. query.equalTo("result",mbti?.result);
  47. query.equalTo("name",mbti?.name);
  48. await query.first();
  49. return await query.first();
  50. }
  51. importAll()