nosql

A bit of advice on Cassandra vs. MySQL

人盡茶涼 提交于 2019-12-06 09:18:52
I asked a question on here a couple of days ago and got some really good answers, i'm thinking about doing a facebook style website with profiles, bio's, etc, and asked whether i should use mysql, the answers were to use Cassandra because its much better. I'm just asking is this what everyone would suggest, its just i know mysql fairly well and would it be a completely stupid move on my part to use mysql over Cassandra (which i hadnt even heard of until 2 days ago) thanks Go for MySQL. Cassandra will make development hard, it still lacks tools, tutorials, etc. And it's rapidly changing, so you

Mongoose positional operator errors

醉酒当歌 提交于 2019-12-06 08:56:54
I am trying to run a command like this in mongoose: Song.update({url: s.url, "playlist.playlist_id": pl._id}, {$set: {"playlist.$.position": 505050}}, function(er, da) { console.log("song on playlist lets change position"); console.log(er); console.log(da); }); however I get the error: [TypeError: Cannot call method 'path' of undefined] I am guessing it has to do with mongoose and $ operator because it works in the mongodb console. Any ideas? I had similar issue with mongoose also, maybe edit your post to see the schema. I fixed my problem by doing the following modification in my schema:< var

How to check if a database exists with mongoose.createConnection()?

故事扮演 提交于 2019-12-06 08:53:23
I want to create multiple connections using mongoose. Therefore, I've chosen to use mongoose.createConnection() instead of mongoose.connect() . When I connect on my localhost, I want to check if the database that I'm connecting to exists. My connection to a non-existing database: let db = mongoose.createConnection('mongodb://localhost/nonexistentdb'); Nevertheless, the events still give the the following results: db.on('open', function() { console.log("Opened"); // <= logged }); db.on('connected', function () { console.log('Connected'); // <= logged }); db.on('error', (err) => { console.log(

query documents that depend on values of other documents in mongodb

本秂侑毒 提交于 2019-12-06 08:48:11
Imagine following mongoose model: const UserSchema = Schema({ //_id: ObjectId, //more fields, blockedIds: [{ type: ObjectId, ref: 'User' }] }) What is the most efficient way to get all users that don't match the blockedIds of an user with a certain _id? A naive way would be to to perform two queries: User.findById(id).then(user => { return User.find({_id: {$nin: user.blockedIds}}) }) Is it possible to use the aggregation framework and $facets to accomplish that in one query? Try non-correlated sub query from 3.6 for your use case. Something like User.aggregate( [{$lookup:{ from: "users",

Fetching all keys using the Cassandra API — analogy to “SELECT id FROM table;”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 08:31:57
问题 The Cassandra command-line utility sstablekeys can be used to extract all defined row keys from a physical SSTABLE file: sstablekeys .../cassandra/data/Keyspace1/Standard1-N-Data.db Does the Cassandra API support retrieval of all defined keys? If so, how? I'm looking for the Cassandra analogy to SELECT id FROM table; . 回答1: Take a look at get_range_slices list<KeySlice> get_range_slices(keyspace, column_parent, predicate, range, consistency_level) which replaces get_range_slice in 0.6. Nb.

MongoDB Table Design and Query Performance

荒凉一梦 提交于 2019-12-06 07:28:09
I'm new to MongoDB. When creating a new table a question came to my mind related to how to design it and performance. My table structure looks this way: { "name" : string, "data" : { "data1" : "xxx", "data2" : "yyy", "data3" : "zzz", .... } } The "data" field could grow until it reaches an amount of 100.000 elements ( "data100.000" : "aaaXXX"). However the number of rows in this table would be under control (between 500 and 1000). This table will be accessed many times in my application and I'd like to maximize the performance of any queries. I would do queries like this one (I'll put an

Is there a nosql store that also allows for relationships between stored entities?

一个人想着一个人 提交于 2019-12-06 07:20:21
问题 I am looking for nosql key value stores that also provide for storing/maintaining relationships between stored entities. I know Google App Engine's datastore allows for owned and unowned relationships between entities. Does any of the popular nosql store's provide something similar? Even though most of them are schema less, are there methods to appropriate relationships onto a key value store? 回答1: It belongs to the core features of graph databases to provide support for relationships between

Why doesn't MongoDB use fsync()?

☆樱花仙子☆ 提交于 2019-12-06 07:12:11
问题 So I have done some research and found out that MongoDB doesn't do fsync(), which means that when you tell the database to write something, the database might tell you it's written, although it's not. Isn't this going against CRUD? If I'm correct, are there any good reasons for this? 回答1: The reason is performance. Without having to write to disk on each change, MongoDB can handle updates faster. MongoDB tells you when updates have been delivered to the server, not when the updates have been

Elasticsearch Aggregation by Day of Week and Hour of Day

十年热恋 提交于 2019-12-06 07:04:34
I have documents of type: [{"msg":"hello", date: "some-date"},{"msg":"hi!", date: "some-date"}, ... I want to have the count of documents by day of week. For example x messages were sent on Monday and y were sent on Tuesday and so on. I have used date_histogram with aggregation but it returns me the documents day wise. It does return me the day, but say "Wed, 22" and "Wed, 29" are returned as separate aggregation documents. This is somewhat related to Elasticsearch - group by day of week and hour but there is no answer to that question so I am reposting it. According to the suggestion there it

Rethinkdb removing data from documents

梦想的初衷 提交于 2019-12-06 06:52:36
I'm trying to remove some portions of data from documents with given fairly simple structure, which will get much deeper and heavier than this as the project goes: { id: "...", name: "...", phone: "...", data: { key1: "val1", ... } ... } I'm aware that there is no way of updating/removing sections from the nested parts other than replacing the whole tree with updated tree. For example, if I want to delete key1 from document data, I need to update the documents data section with a copy of it where key1 is not contained document.update({data: new dict without key1}) Is there any eaiser way of