createtable necessary if the table already exists?
wuichen opened this issue · 3 comments
wuichen commented
do i have to call createtable everytime when i want to do create an item in an existing table? If not, how to do so? The only operation i need is CRUD on existing tables. im working on lambda functions.
clarkie commented
Hi @wuichen, you don't need to call createTables
on every call. If you can "guarantee" that the table is there and accessible by the Lambda function then you can just interact with it using query
, scan
, etc as needed.
wuichen commented
@clarkie are there any examples showing how to do simple create without createTable?
clarkie commented
Something like this?
const schema = {
id: joi.string(),
name: joi.string(),
};
const userTable = dynogels.define('user', {
hashKey: 'id',
timestamps: true,
schema,
});
function create(user) {
const id = uuid.v4();
return userTable
.createAsync(Object.assign({ id }, user))
.then(console.log);
}