问题描述
我们想在AWS中运行Apostrophe,但是我们的政策是使用Dynamo DB满足我们的数据库需求。
这可能吗?
We would like to run Apostrophe in AWS, however our policy is to use Dynamo DB for our database needs.Is this possible?
在
它说:
我认为
我尝试扩展apostrophe-db模块来调用
I have tried extending the apostrophe-db module to call
self.apos.db = new AWS.DynamoDB();
但是该站点不会初始化。
But the site won't initialise.
任何尝试过此操作的人都可以在可能的情况下举一些例子。
Can anyone who has attempted this please give some examples of how to do it if it is possible.
谢谢
推荐答案
如果要使基本的Apostrophe-CMS模块使用MongoDB以外的其他语法的数据库,则需要进行很多工作。除非我非常误解,否则Dynamo DB不会使用与MongoDB相同的查询语法。 Apostrophe-CMS不具备即时切换到其他数据库的功能-您需要在几个Apostrophe模块中重写很多代码才能实现此目的,因为Apostrophe是为与MongoDB配合使用而编写的。例如,撇号文档模块可以访问Apostrophe用于存储其大部分数据的文档集合。您可以在此处查看docs模块的设置方式:
If you want to make the base Apostrophe-CMS modules use a database with a syntax other than MongoDB's, you'd be in for a lot of work. Unless I'm very much mistaken, Dynamo DB doesn't use the same query syntax as MongoDB. Apostrophe-CMS doesn't contain the ability to switch to other databases on the fly - you'd need to rewrite a lot of the code in a few Apostrophe modules in order to accomplish this, since Apostrophe is written to work with MongoDB. As an example, the apostrophe-docs module is what gives access to the documents collection that Apostrophe uses to store most of its data. You can see how the docs module is set up here: https://github.com/apostrophecms/apostrophe/blob/master/lib/modules/apostrophe-docs/lib/api.js
注意该模块中有多少代码正在使用特定于MongoDB的查询语法。由于Apostrophe具有出色的继承系统,可能有可能覆盖Apostrophe用于访问MongoDB的每一段代码,并用代码替代其访问另一数据库的代码,但这可能是一项令人难以置信的工作。
Notice how much of the code in that module is using a query syntax specific to MongoDB. Because of Apostrophe's wonderful inheritance system, it would probably be possible to overwrite every bit of code that Apostrophe uses to access MongoDB and replace it with code to access another database, but it would probably be an incredible amount of work.
您在问题中引用的行似乎是指仅在自定义模块内部连接到另一个数据库。例如,如果您要创建一个从SQL数据库而不是从Apostrope mongodb docs集合中提取的Comment小部件,则可以引入诸如node-mssql之类的NPM包,并在其中覆盖许多默认的Apostrophe-CMS小部件行为您的评论模块。这样,您就可以为该特定模块提取任何数据,但是Apostrophe仍需要从其MongoDB实例中提取数据。
The line you reference in your question seems to be referring to connecting to another database only inside of your custom modules. For example, if you want to create a Comments widget that pulls from a SQL database instead of from the Apostrope mongodb docs collection, you could pull in an NPM package like node-mssql and override lots of the default Apostrophe-CMS widget behavior inside of your Comments module. This would allow you to pull whatever data you'd like for that particular module, but Apostrophe would still need to be pulling data from its MongoDB instance.
这篇关于与Dynamo DB一起运行的Apostrophe CMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!