You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Creating a beaconvarnewBeacon={}newBeacon.name="New beacon"newBeacon.uuid="7EA016FB-B7C4-43B0-9FCC-AAB391AE1722"newBeacon.major=100newBeacon.minor=1newBeacon.tags="beacon-tag"beacon.create(newBeacon.tags,newBeacon.name,newBeacon.uuid,newBeacon.major,newBeacon.minor)console.log("Created beacon '"+newBeacon.name+"'")
Retrieving by Tag
// Retrieving a beacon by tagsvarbeaconsFoundByTag=beacon.tagged("beacon-tag")if(beaconsFoundByTag.length>0){varfirstBeacon=beaconsFoundByTag[0]if(firstBeacon){console.log("Listing data from first beacon with tag 'beacon-tag'")console.log("Found by 'beacon-tag' beacon id: "+firstBeacon.id)console.log("Found by 'beacon-tag' beacon name: "+firstBeacon.name)console.log("Found by 'beacon-tag' beacon UUID: "+firstBeacon.uuid)console.log("Found by 'beacon-tag' beacon major: "+firstBeacon.major)console.log("Found by 'beacon-tag' beacon minor: "+firstBeacon.minor)console.log("Found by 'beacon-tag' beacon tags: "+firstBeacon.tags)}}
Retrieving by ID
// Retrieving a beacon by IDvarbeaconID=1500varbeaconFoundByID=beacon.find(beaconID)if(beaconFoundByID){console.log("Listing data from beacon with id: "+beaconID)console.log("Found by 'ID' beacon name: "+beaconFoundByID.name)console.log("Found by 'ID' beacon UUID: "+beaconFoundByID.uuid)console.log("Found by 'ID' beacon major: "+beaconFoundByID.major)console.log("Found by 'ID' beacon minor: "+beaconFoundByID.minor)console.log("Found by 'ID' beacon tags: "+beaconFoundByID.tags)}
Updating
// Updating a beaconvarbeaconID=1500varupdatedBeacon={}updatedBeacon.name="Update beacon"updatedBeacon.uuid="E004D972-7BB7-47C8-9DCE-E091CB103500"updatedBeacon.major=200updatedBeacon.minor=2updatedBeaconTags="beacon-tag,beacon2-tag"beacon.update(beaconID,JSON.stringify(updatedBeacon),updatedBeaconTags)
Deleting
// Deleting a beaconvarbeaconID=1500beacon.destroy(beaconID)