{
_id:'1',
name:'apple',
option:[{
weight:'10',
price:'40',
},
{weight:'40',
price:'200'}]
}
Run Code Online (Sandbox Code Playgroud)
我要添加苹果(如果不在db中),如果要在db中添加,如果重量10可用,我要确认,如果可用,我要更新价格,否则,我想添加新的重量和价格。在mongodb中,我该怎么做。
我能够成功地从我的服务器获取推送通知并使用此更新反应组件
self.addEventListener('push', event => {
const data = event.data.json();
event.waitUntil(
self.registration.showNotification(data.title, {
body: data.body,
image: './Flowster-icon-32.png'
})
);
const channel = new BroadcastChannel('sw-messages');
channel.postMessage(data);
});
Run Code Online (Sandbox Code Playgroud)
但是浏览器 IE、safari、donto 支持 BroadcastChannel,甚至这些浏览器不支持 client.postMessage,我怎样才能让它在这些浏览器中工作。我在这里先向您的帮助表示感谢。