Shopping Mall directory
Building a shopping mall directory
Let’s look at the needs of application used to manage Shopping Mall properties. The application assists employees in the day-to-day operations of multiple Shopping Malls.
Requirements
- As a Maintenance Worker, I need to know which stores are currently in each Mall down to the Building they are located.
- As a Helpdesk Employee, I need to locate related stores in Mall locations by Store Category.
- As a Property Manager, I need to identify upcoming leases in need of renewal.
Each example below is self-contained: the Entity and Table Definition tabs show the setup that example runs against, and the generated parameters are produced live by executing the example.
Mutations
Add a new Store to the Mall
import { StoreLocations } from "./entity";
await StoreLocations.create({
mallId: "EastPointe",
storeId: "LatteLarrys",
buildingId: "BuildingA1",
unitId: "B47",
cityId: "Atlanta1",
category: "spite store",
leaseEndDate: "2020-02-29",
rent: "5000.00",
}).go();Change the Stores Lease Date
When updating a record, you must include all Composite Attributes associated with the table’s primary PK and SK.
import { StoreLocations } from "./entity";
let storeId = "LatteLarrys";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let cityId = "Atlanta1";
await StoreLocations.patch({ storeId, mallId, buildingId, cityId })
.set({ leaseEndDate: "2021-02-28" })
.go();Retrieve a specific Store in a Mall
When retrieving a specific record, you must include all Composite Attributes associated with the table’s primary PK and SK.
import { StoreLocations } from "./entity";
let storeId = "LatteLarrys";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let cityId = "Atlanta1";
await StoreLocations.get({ storeId, mallId, buildingId, cityId }).go();Remove a Store location from the Mall
When removing a specific record, you must include all Composite Attributes associated with the table’s primary PK and SK.
import { StoreLocations } from "./entity";
let storeId = "LatteLarrys";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let cityId = "Atlanta1";
await StoreLocations.delete({ storeId, mallId, buildingId, cityId }).go();Queries
All Stores in a particular mall
Fulfilling Requirement #1.
import { StoreLocations } from "./entity";
let mallId = "EastPointe";
let stores = await StoreLocations.query.units({ mallId }).go();All Stores in a particular mall building
Fulfilling Requirement #1.
import { StoreLocations } from "./entity";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let stores = await StoreLocations.query.units({ mallId, buildingId }).go();Find the store located in unit B47
Fulfilling Requirement #1.
import { StoreLocations } from "./entity";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let unitId = "B47";
let stores = await StoreLocations.query
.units({ mallId, buildingId, unitId })
.go();Stores by Category at Mall
Fulfilling Requirement #2.
import { StoreLocations } from "./entity";
let mallId = "EastPointe";
let category = "food/coffee";
let stores = await StoreLocations.query
.units({ mallId })
.where((attr, op) => op.eq(attr.category, category))
.go();Stores by upcoming lease
Fulfilling Requirement #3.
import { StoreLocations } from "./entity";
let storeId = "LatteLarrys";
let q2StartDate = "2020-04-01";
let stores = await StoreLocations.query
.leases({ storeId })
.lt({ leaseEndDate: q2StartDate })
.go();Stores will renewals for Q4
Fulfilling Requirement #3.
import { StoreLocations } from "./entity";
let storeId = "LatteLarrys";
let q4StartDate = "2020-10-01";
let q4EndDate = "2020-12-31";
let stores = await StoreLocations.query
.leases({ storeId })
.between({ leaseEndDate: q4StartDate }, { leaseEndDate: q4EndDate })
.go();Spite-stores with release renewals this year
Fulfilling Requirement #3.
import { StoreLocations } from "./entity";
let storeId = "LatteLarrys";
let yearStarDate = "2020-01-01";
let yearEndDate = "2020-12-31";
let stores = await StoreLocations.query
.leases({ storeId })
.between({ leaseEndDate: yearStarDate }, { leaseEndDate: yearEndDate })
.where((attr, op) => op.eq(attr.category, "spite store"))
.go();All Latte Larry’s in a particular mall building
import { StoreLocations } from "./entity";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let storeId = "LatteLarrys";
let stores = await StoreLocations.query
.units({ mallId, buildingId, storeId })
.go();