How to query local dynamoDB using dynamoose?(如何使用 dynamoose 查询本地 dynamoDB?)
问题描述
作为开发人员,我不想一直连接到 Amazon Web 服务,我在本地计算机上安装了 DynamoDB,参考 AWS 文档.我在后端使用 node.js.
As a developer, i don't want to connect all the time to Amazon web services, and I installed DynamoDB in my local computer referring the AWS Docs. I am using node.js in the backend.
我在生产中使用 dynamoose 作为 Amazon DynamoDB 的建模工具,如何使用相同的 dynamoose 查询本地 DynamoDB 表进行开发?
I am using dynamoose as the modeling tool for Amazon's DynamoDB in my production, How can I use the same dynamoose for querying my local DynamoDB tables for development?
推荐答案
你只需在你的代码中使用这个:
You just use this in your code:
dynamoose.local();
假设您的应用程序中有一个属性文件,您可能需要一个属性标志来指示您是处于开发阶段还是生产阶段.然后在您的代码中,获取属性,如果您处于开发阶段,请运行 dynamoose.local() 行.
Assuming you have a properties file in your application, you probably want a property flag to indicate whether you are in Development or Production. Then in your code, get the property, if you are in Development, run the dynamoose.local() line.
我不会用 javascript 编写代码,但它会是这样的:
I don't code in javascript but it will be something like:
const { NODE_ENV } = process.env
if (NODE_ENV == "DEV") {
dynamoose.local();
}
这假设您的应用程序中有一个属性文件,您在其中设置了一个名为环境"的系统属性.具有说DEV"的值或产品".
This assume you have a properties file in your application where you set a system property called "environment" to have a value of say "DEV" or "PROD".
这篇关于如何使用 dynamoose 查询本地 dynamoDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 dynamoose 查询本地 dynamoDB?
基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
