Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Dynamoose Examples

node v8.17.0
version: 3.0.0
endpointsharetweet
A simple example for connecting, creating a model, and logging out a result.
const dynamoose = require('dynamoose'); const dynalite = require('dynalite'); const startUpAndReturnDynamo = async () => { const dynaliteServer = dynalite(); await dynaliteServer.listen(8000); return dynaliteServer; }; const createDynamooseInstance = () => { dynamoose.AWS.config.update({ accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-east-1' }); dynamoose.local(); // This will set the server to "http://localhost:8000" (default) } const createAndGetCat = async () => { const Cat = dynamoose.model('Cat', {id: Number, name: String}); const garfield = new Cat({id: 666, name: 'Garfield'}); await garfield.save(); const badCat = await Cat.get(666); return badCat; } const bootStrap = async () => { await startUpAndReturnDynamo(); createDynamooseInstance(); const badCat = await createAndGetCat(); console.log('Never trust a smiling cat. - ' + badCat.name); } bootStrap();
Loading…

no comments

    sign in to comment