On this page

On this page

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

  1. As a Maintenance Worker, I need to know which stores are currently in each Mall down to the Building they are located.
  2. As a Helpdesk Employee, I need to locate related stores in Mall locations by Store Category.
  3. 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

Edit in Playground ↗
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();
Generated DynamoDB Parameters
Generating parameters…

Change the Stores Lease Date

When updating a record, you must include all Composite Attributes associated with the table’s primary PK and SK.

Edit in Playground ↗
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();
Generated DynamoDB Parameters
Generating parameters…

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.

Edit in Playground ↗
import { StoreLocations } from "./entity";

let storeId = "LatteLarrys";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let cityId = "Atlanta1";

await StoreLocations.get({ storeId, mallId, buildingId, cityId }).go();
Generated DynamoDB Parameters
Generating parameters…

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.

Edit in Playground ↗
import { StoreLocations } from "./entity";

let storeId = "LatteLarrys";
let mallId = "EastPointe";
let buildingId = "BuildingA1";
let cityId = "Atlanta1";

await StoreLocations.delete({ storeId, mallId, buildingId, cityId }).go();
Generated DynamoDB Parameters
Generating parameters…

Queries

All Stores in a particular mall

Fulfilling Requirement #1.

Edit in Playground ↗
import { StoreLocations } from "./entity";

let mallId = "EastPointe";

let stores = await StoreLocations.query.units({ mallId }).go();
Generated DynamoDB Parameters
Generating parameters…

All Stores in a particular mall building

Fulfilling Requirement #1.

Edit in Playground ↗
import { StoreLocations } from "./entity";

let mallId = "EastPointe";
let buildingId = "BuildingA1";

let stores = await StoreLocations.query.units({ mallId, buildingId }).go();
Generated DynamoDB Parameters
Generating parameters…

Find the store located in unit B47

Fulfilling Requirement #1.

Edit in Playground ↗
import { StoreLocations } from "./entity";

let mallId = "EastPointe";
let buildingId = "BuildingA1";
let unitId = "B47";

let stores = await StoreLocations.query
  .units({ mallId, buildingId, unitId })
  .go();
Generated DynamoDB Parameters
Generating parameters…

Stores by Category at Mall

Fulfilling Requirement #2.

Edit in Playground ↗
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();
Generated DynamoDB Parameters
Generating parameters…

Stores by upcoming lease

Fulfilling Requirement #3.

Edit in Playground ↗
import { StoreLocations } from "./entity";

let storeId = "LatteLarrys";
let q2StartDate = "2020-04-01";

let stores = await StoreLocations.query
  .leases({ storeId })
  .lt({ leaseEndDate: q2StartDate })
  .go();
Generated DynamoDB Parameters
Generating parameters…

Stores will renewals for Q4

Fulfilling Requirement #3.

Edit in Playground ↗
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();
Generated DynamoDB Parameters
Generating parameters…

Spite-stores with release renewals this year

Fulfilling Requirement #3.

Edit in Playground ↗
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();
Generated DynamoDB Parameters
Generating parameters…

All Latte Larry’s in a particular mall building

Edit in Playground ↗
import { StoreLocations } from "./entity";

let mallId = "EastPointe";
let buildingId = "BuildingA1";
let storeId = "LatteLarrys";

let stores = await StoreLocations.query
  .units({ mallId, buildingId, storeId })
  .go();
Generated DynamoDB Parameters
Generating parameters…