Skip to content

Latest commit

 

History

History
89 lines (64 loc) · 3.18 KB

rooms.md

File metadata and controls

89 lines (64 loc) · 3.18 KB

🗀 ROOMS

C_ROOMS extends COMMON_COMPONENT

Component to manage/update rooms, which should represent your phiscal building.


Table of contents

  • Schema
  • Methods
    • Add Add new deivce
    • Get Get existing Room
    • Remove Removes exisiting Room
    • Update Update Room
    • Find Find Room in database
  • Classes

Schema

Name Type Required Default value Description
_id String ObjectId MongoDB ObjectID converted to a String
name String x Human friendly name e.g. "Living room", "Bed room"
number Number Room number
floor Number Floor number on which the rooms is located
icon String Icon name
timestamps Object Timestamps, when something was done to the object e.g. created/updated
timestamps.created Number Date.now() Unix timestamp, set when .add is called to Date.now()
timestamps.updated Number null Unix timestamp, set to Date.now() when .update is called

Example

{
  "_id":"6032794756b6681d420d1946",
  "name":"Kitchen",
  "timestamps":{
    "created":1613920583473,
    "updated":null
  }
}

Methods

add(data[,cb])

  • data {Object} Object structure as defined in schema.
  • cb {Function} Callback function, if absent, a promise is returned.

Add a new Room to the database and creates a Room instance

get(id[,cb])

  • id {String} Room id as defined in schema.
  • cb {Function} Callback function, if absent, a promise is returned.

Get a Room from the .items array

remove(id[,cb])

  • id {String} Room id as defined in schema.
  • cb {Function} Callback function, if absent, a promise is returned.

Removes a Room from the database

update(id, data[,cb])

  • id {String} Room id as defined in schema.
  • data {Object} Properties to update on Room id object/instance.
  • cb {Function} Callback function, if absent, a promise is returned.

Updates a Room object in database & Room instance in .items array

find(obj[,cb])

  • obj {Object} Key/value to look for Rooms.
  • cb {Function} Callback function, if absent, a promise is returned.

Find Room with mathing key/values pair in the .items array


Classes

class.rooms.js

Represent a Room instance