Skip to content

Commit

Permalink
DEV: complete *Item API for table
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Jan 15, 2021
1 parent cb03a8b commit e65b4c9
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ export default class Table {
// Context properties always applied to create/updates
this.context = {}

// Model for uunique properties and for multi-table and low level API

// Model for uunique properties and for genric access
this.unique = new Model(this, '_Unique', {fields: UniqueSchema, timestamps: false})
this.model = new Model(this, '_Multi', {fields: LowLevelSchema, timestamps: false})
this.generic = new Model(this, '_Multi', {fields: LowLevelSchema, timestamps: false})

if (schema) {
this.prepSchema(schema)
Expand Down Expand Up @@ -151,15 +150,16 @@ export default class Table {
return await model.get(properties, params)
}

async delete(modelName, properties, params) {
return await this.remove(modelName, properties, params)
}

async remove(modelName, properties, params) {
let model = this.getModel(modelName)
return await model.remove(properties, params)
}

async scan(modelName, properties, params) {
let model = this.getModel(modelName)
return await model.scan(properties, params)
}

async update(modelName, properties, params) {
let model = this.getModel(modelName)
return await model.update(properties, params)
Expand Down Expand Up @@ -191,12 +191,28 @@ export default class Table {
return result
}

async deleteItem(properties, params) {
return await this.generic.deleteItem(properties, params)
}

async getItem(properties, params) {
return await this.generic.getItem(properties, params)
}

async putItem(properties, params) {
return await this.generic.putItem(properties, params)
}

async queryItems(properties, params) {
return await this.model.queryItems(properties, params)
return await this.generic.queryItems(properties, params)
}

async scanItems(properties, params) {
return await this.generic.scanItems(properties, params)
}

async scanItems(params) {
return await this.model.scanItems(params)
async updateItem(properties, params) {
return await this.generic.updateItem(properties, params)
}

/*
Expand Down

0 comments on commit e65b4c9

Please sign in to comment.