我正在使用 Google App Engine,因此我使用的是非关系数据库 (NoSQL)。我的问题是:
使用得分建模排名(玩家排名)的最佳选择是什么?
例如,我的球员是:
Player { String name, int score}
Run Code Online (Sandbox Code Playgroud)
我想知道一名球员的排名(位置)并获得前 10 名球员,但我怀疑这是最好的方法。
谢谢。
google-app-engine database-design ranking nosql amazon-simpledb
我有一个 GET all products 端点,它需要很长时间才能返回响应:
Product.find(find, function(err, _products) {
if (err) {
res.status(400).json({ error: err })
return
}
res.json({ data: _products })
}).sort( [['_id', -1]] ).populate([
{ path: 'colors', model: 'Color' },
{ path: 'size', model: 'Size' },
{ path: 'price', model: 'Price' }
]).lean()
Run Code Online (Sandbox Code Playgroud)
尽管产品集合中只有 60 个文档,但此查询最多需要4 秒。
这个查询来自以前的开发人员,我对 Mongoose 不太熟悉。
什么是性能后果sort和populate?我认为populate是这里的罪魁祸首?我不太确定populate在做什么,所以我不清楚如何避免它或在数据库级别建立索引以提高性能。
我需要在 AWS DynamoDB 中维护一对多关系数据。例如,一名员工可以拥有多种技能映射到他身上。在典型的 RDBMS 中,我将创建一个SKILL_MASTER表,其中SkillId、SkillName作为列和EMPLOYEE表。然后,我会在地图SkillId的雇员在EMPLOYEE表。DynamoDB 中的正确方法是什么?
注意:我对 NoSQL 完全陌生,因此是这个基本问题。
这怎么可能?NoSQL 是什么让它比某些 RDBMS 具有更高的写入吞吐量?是否归结为可扩展性?
我想创建一个交易模块,在成功交易后,用户文档(在这种情况下用户向另一个用户汇款)也将被更新。
一种。在 user.js(这是用户模型)中,除了姓名、密码、电子邮件(等)我创建了这个属性,它将保存各个用户的交易相关历史记录。请看看我是如何使用它的:
transaction_history:[{
transactionid:String,
timestamp:String,
type:String,
balance:Number,
status:String
}]
Run Code Online (Sandbox Code Playgroud)
湾 当发件人点击表单中的发送按钮时,会创建一个交易文档,然后用户文档(这里是发件人)应该与交易信息一起更新。
//create transaction document, works fine
Transaction.create({transactionid:uniqid(),
timestamp:moment().format(datemask),
amount:balance,
sender:sendfrom,
receiver:sendto,
status:"done"
}, function(err, tr){
if(err) throw err;
else {
//I want sender document to update with transaction info
User.findOne({email:sendfrom}, function(err, sendfrom){
if(err) {console.log("error at sender side");}
else
if(sendfrom!=null){
// console.log("tr: "+tr); //fine
sendfrom.balance-=balance;
sendfrom.transaction_history.push({
transactionid:tr.transactionid,
// timestamp:tr.timestamp,
// type:"debit",
// balance:tr.amount,
// status:tr.status
}
);
sendfrom.save();
console.log("sender's current balance is: "+sendfrom.balance);
};
});
}});
Run Code Online (Sandbox Code Playgroud)
C。但后来我得到了这个:
events.js:163
throw er; …Run Code Online (Sandbox Code Playgroud) 我的 MongoDB 中有一个数据库列表。如何删除除所有数据库local,admin和config?

我创建了一个 Listview 构建器buildChatList作为我的 itembuilder传递,但我注意到buildChatList当我热重启或重建应用程序时没有返回任何内容,但当我热重载时实际上返回了预期的数据。我不明白为什么会这样。我需要帮助。
以下是我到目前为止的代码。
buildChatList(BuildContext context, int index) {
Map<String, dynamic> userDocumentt;
print('INDEX $index COUNT $currentUserActiveChatsLength');
String thisUserID = currentUserActiveChats[index];
if (user.uid.hashCode <= thisUserID.hashCode) {
groupChatId = '$_cuserID-$thisUserID';
} else {
groupChatId = '$thisUserID-$_cuserID';
}
Stream<QuerySnapshot> unreadMessages = Firestore.instance
.collection('messages')
.where("chatDetails.to", isEqualTo: user.uid)
.where("chatDetails.sender", isEqualTo: thisUserID)
.where("chatDetails.hasRead", isEqualTo: false)
.snapshots();
unreadMessages.listen((QuerySnapshot data) {
unReadMessageLength = data.documents.length;
});
Stream<QuerySnapshot> lastMess = Firestore.instance
.collection('messages')
.where('groupChatId', isEqualTo: groupChatId)
.orderBy('chatDetails.timestamp', descending: true)
.limit(1)
.snapshots();
lastMess.listen((QuerySnapshot data) {
List<DocumentSnapshot> userLastMess …Run Code Online (Sandbox Code Playgroud) 我正在设计一个 DynamoDB 数据库表。例如test_table,在一张表中,我定义了一个组合键,其中包含一个分区键(比如)partition_id和一个排序键(比如)sort_id。双方partition_id并sort_id可能在他们的条目一些重复的值,但两者的结合partition_id,并sort_id一起将永远是独一无二的。
我想知道,如何有效的是具有一些共有的记录检索partition_id,说partition_id = x?
我试图在社交网络的 nosql db 模型中遵循“一张表”原则。但它给我带来了很多问题。
假设我的模型现在看起来像这样:
Table-Groups
{
name: "Group1"
topics: [
name: "Topic1"
posts: [
{
id: "tid1"
author: "Walter White"
message: "Hello from Post1"
comments: [
{
id: "cid1"
author: "Jessy"
message: "Yo nice post Mr. White"
}
{
id: "cid2"
author: "Saul"
message: "Jeze Walt"
}
]
}
//... Many other posts here
]
//... Many other topics within the group
]
}
//... Not so many other groups
Run Code Online (Sandbox Code Playgroud)
我可以对帖子或评论数组进行分页吗?
因为我会(理论上)在 post 数组中有很多帖子,所以我必须阅读大量数据,而实际上我只想阅读最新的 10 个帖子。帖子中的数组评论也是如此。有没有可能对这些数组进行分页?
我可以将主题数组中的属性“name”用作 sortKey 吗?(topic.name) …
从架构的角度:能否请您帮我理解为什么 NoSQL DynamoDB 如此炒作。
DynamoDB 通过在任何规模上提供一致的个位数毫秒响应时间来支持一些世界上最大规模的应用程序。
我试图批评,以了解问题的原因。我们总是必须在检索时指定分区键和键属性以获得毫秒级的性能
如果我设计 RDBMS:
它是不是与 NoSQL 架构一样,没有任何营销嗡嗡声?
无论如何,我们正在转向 DynamoDB,但这是我无辜的好奇心,RDMBS 无法做到的一定有充分的理由。让我们跳过备份和维护优势等。