考虑到以下情况,如何确定计算机列表是否为空,以便添加计算机?
let gun = new Gun();
let machines = gun.get('machines');
如何检查机器列表是否为空?
发布于 2018-01-16 05:20:48
这来自马克·纳达尔:
// machineId and location defined elsewhere
machines.val(table => {
if (Gun.obj.empty(table, '_') {
// table is empty so we can add something to it
let machine = gun.get('machine/' + machineId);
machine.put({machineId, location}};
machines.set(machine);
} else {
// table is not empty
})
https://stackoverflow.com/questions/48270815
复制相似问题