Book.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 lqlBook = [
  7. { name: '朝花夕拾', image: 'assets/image/ZhaoHuaXiShi.webp', author: '朝花夕拾的详情描述', rating: 8.5 },
  8. { name: '西游记', image: 'assets/image/XiYouJi.webp', author: '西游记的详情描述', rating: 9.3 },
  9. { name: '红楼梦', image: 'assets/image/HongLouMeng.webp', author: '红楼梦的详情描述', rating: 8.0 },
  10. { name: '水浒传', image: 'assets/image/ShuiHuZhuan.webp', author: '水浒传的详情描述', rating: 8.7 },
  11. { name: '简·爱', image: 'assets/image/JianAn.webp', author: '哆啦A梦的详情描述', rating: 9.4},
  12. { name: '雾都孤儿', image: 'assets/image/WuDuGuEr.webp', author: '哆啦A梦的详情描述', rating: 9.2 },
  13. { name: '鲁滨孙漂流记', image: 'assets/image/RuBinSui.webp', author: '哆啦A梦的详情描述', rating: 9.1 },
  14. { name: '孙子兵法', image: 'assets/image/SuiZiBinFu.webp', author: '哆啦A梦的详情描述', rating: 9.5 },
  15. { name: '周易', image: 'assets/image/ZhouYi.webp', author: '哆啦A梦的详情描述', rating: 9.6 },
  16. { name: '三十六计', image: 'assets/image/SanShiLiuJi.webp', author: '哆啦A梦的详情描述', rating: 9.4 },
  17. { name: '诗经', image: 'assets/image/ShiJin.webp', author: '哆啦A梦的详情描述', rating: 9.3 },
  18. ];
  19. function importAll(){
  20. let LQLBook= []
  21. Object.keys(lqlBook).forEach(key=>{
  22. LQLBook.push({
  23. // result:key,
  24. name:lqlBook[key]?.name,
  25. author:lqlBook[key]?.author,
  26. rating:lqlBook[key]?.rating,
  27. image:lqlBook[key]?.image,
  28. })
  29. })
  30. console.log(LQLBook)
  31. LQLBook.forEach(async mbti => {
  32. // 查重
  33. let exists = await checkExists(mbti)
  34. if(exists?.id) return;
  35. // 新增
  36. let LQLBook = Parse.Object.extend("LQLBook");
  37. let bm = new LQLBook();
  38. bm.set(mbti);
  39. bm.save();
  40. });
  41. }
  42. async function checkExists(mbti){
  43. let query = new Parse.Query("LQLBook");
  44. query.equalTo("result",mbti?.result);
  45. query.equalTo("name",mbti?.name);
  46. await query.first();
  47. return await query.first();
  48. }
  49. importAll()