1.0.6 • Published 3 years ago
mongoose-home-management v1.0.6
��# mongoose-home-management
mongoose-home-management provides mongoose models for managing a home like structure.
- Homes can have multiple users and a name.
- Rooms can be linked to one home and also have a name.
- Devices can be linked to one room and also have a name.
Installation
npm install mongoose-home-management
Usage
For rooms and devices, a similar implementation can be used as found below.
import { IHome, HomeModel } from 'mongoose-user-schema';
//Creating a new home
const createNewHome = async (userId: ObjectID, name: string) => {
let newHome: IHome = new HomeModel({ userIds: [userId], name: name });
await newHome.save();
}
//Return all homes
const getHomes = async (): Promise<IHome[]> => {
return await HomeModel.find({});
}