当前位置: 首页 > 后端技术 > Node.js

野狗与微信小程序的结合

时间:2023-04-03 13:37:27 Node.js

wilddog-weappWilddog(wilddog)微信小程序客户端(预览版)注:由于微信尚未正式发布小程序,此版本为预览版,请勿用于正式制作环境已知问题:在微信开发者工具中,会有一定概率无法连接野狗服务器。目前只支持数据同步部分功能,不支持授权和用户管理相关功能。项目地址https://github.com/WildDogTea...引入wilddog客户端将wilddog-weapp-all.js直接放到微信小程序项目中使用commonjs引入varwilldog=require('wilddog-weapp-all')初始化varconfig={syncURL:}wilddog.initializeApp(config)使用on、once、set、push、update等API进行数据同步操作。例如:varref=willdog.sync().ref('demo')ref.on('child_changed',(snapshot)=>{varvalue=snapshot.val()console.log(value)})ref。on('child_changed',(snapshot)=>{//youcode})ref.orderByPriority().limitToFirst(100).once('value',(snapshot)=>{varkey=snapshot.key()varvalue=snapshot.val()})ref.child('abc').set(123)ref.child('abc').push('helloworld',function(err){if(err){//synctocloudwitherror}else{//OK!}})详情参考https://docs.wilddog.com/api/...支持Wilddog.syncAllAPIDEMO目前只写了一个粗略的demohttps:///github.com/stackOverM...contribute欢迎各种问题和代码。原文地址http://jack-x.engineer/2016/1...