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?


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01