系统相关
首页 > 系统相关> > [AWS] windows下安装可视化dynamodb-admin连接本地dynamodb-local以及dynamoose模块测试

[AWS] windows下安装可视化dynamodb-admin连接本地dynamodb-local以及dynamoose模块测试

作者:互联网

1、前置条件java环境自行安装

2、window下启动local_dynamodb

官方报下载:https://docs.aws.amazon.com/zh_cn/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html

下载windows版本,解压后进入目录,执行

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar –sharedDb

会有log4j2的报错,不影响使用,修复教程:https://stackoverflow.com/questions/64549078/dynamodb-local-error-statuslogger-log4j2-could-not-find-a-logging-implementatio

3、安装启动dynamodb_admin

安装:npm install -g dynamodb-admin

设置local-db的地址:set DYNAMO_ENDPOINT=http://localhost:8000

启动:dynamodb-admin

网页访问本地8001端口

4、本地测试

const dynamoose = require("dynamoose");
dynamoose.aws.ddb.local("http://localhost:8000");
console.log('create cat model with default options');
const Cat = dynamoose.model('Cat', {
    id: Number,
    name: String
});
console.log('create a new cat object');
const garfield = new Cat({
    id: 777,
    name: 'Bluecat'
});
console.log('save to local dynamodb');
garfield.save().then(data => {
    console.log('save ' + JSON.stringify(data) +' to local dynamodb');
    if (data) {
        return Cat.get(777)
    }
}).then(data => {
    console.log('lookup in dynamodb');
    console.log('badCat' + JSON.stringify(data));
    console.log(`Never trust a smiling cat. - ${data.name}`);
}).catch(error => {
    console.log(error)
});

执行注册,数据库也写入了数据

 

标签:console,log,dynamoose,data,dynamodb,windows,local
来源: https://blog.csdn.net/BurstLinking/article/details/110468817