1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // 导入BoleMbti脚本
- // 引用Parse JS SDK
- const Parse = require("parse/node");
- Parse.initialize("dev"); // 设置applicationId
- Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL
- let lqlBook = [
- { name: '朝花夕拾', image: 'assets/image/ZhaoHuaXiShi.webp', author: '朝花夕拾的详情描述', rating: 8.5 },
- { name: '西游记', image: 'assets/image/XiYouJi.webp', author: '西游记的详情描述', rating: 9.3 },
- { name: '红楼梦', image: 'assets/image/HongLouMeng.webp', author: '红楼梦的详情描述', rating: 8.0 },
- { name: '水浒传', image: 'assets/image/ShuiHuZhuan.webp', author: '水浒传的详情描述', rating: 8.7 },
- { name: '简·爱', image: 'assets/image/JianAn.webp', author: '哆啦A梦的详情描述', rating: 9.4},
- { name: '雾都孤儿', image: 'assets/image/WuDuGuEr.webp', author: '哆啦A梦的详情描述', rating: 9.2 },
- { name: '鲁滨孙漂流记', image: 'assets/image/RuBinSui.webp', author: '哆啦A梦的详情描述', rating: 9.1 },
- { name: '孙子兵法', image: 'assets/image/SuiZiBinFu.webp', author: '哆啦A梦的详情描述', rating: 9.5 },
- { name: '周易', image: 'assets/image/ZhouYi.webp', author: '哆啦A梦的详情描述', rating: 9.6 },
- { name: '三十六计', image: 'assets/image/SanShiLiuJi.webp', author: '哆啦A梦的详情描述', rating: 9.4 },
- { name: '诗经', image: 'assets/image/ShiJin.webp', author: '哆啦A梦的详情描述', rating: 9.3 },
- ];
-
- function importAll(){
-
- let LQLBook= []
- Object.keys(lqlBook).forEach(key=>{
- LQLBook.push({
- // result:key,
- name:lqlBook[key]?.name,
- author:lqlBook[key]?.author,
- rating:lqlBook[key]?.rating,
- image:lqlBook[key]?.image,
- })
- })
- console.log(LQLBook)
- LQLBook.forEach(async mbti => {
- // 查重
- let exists = await checkExists(mbti)
- if(exists?.id) return;
- // 新增
- let LQLBook = Parse.Object.extend("LQLBook");
- let bm = new LQLBook();
- bm.set(mbti);
- bm.save();
- });
- }
- async function checkExists(mbti){
- let query = new Parse.Query("LQLBook");
- query.equalTo("result",mbti?.result);
- query.equalTo("name",mbti?.name);
- await query.first();
- return await query.first();
- }
- importAll()
|