Couchdb, couch-connector and multiple databases - javascript

I'm wondering if anyone has tried the get couch-connector to work with multiple databases.
I have couchapp which uses multiple databases and I'm having trouble with couch-connector to work with it. Couch-connector works great when I'm using one database, but if I try to fetch a collection from another database view I have problem, because it uses my main design document in url.
One more question: what's the best practice for implementing a chat app in my project. Is it better to have one database as inbox or should I make databases for every user. Im concered for scallability of app in case of one inbox database.

couch_connector isn't really built to do more than a single database. You might checkout backbone.couchdb.js if you're not too far along in your project. It supports multiple databases via code like:
var main_db = Backbone.couch.db('main');
var other_db = Backbone.couch.db('other');
You can see some sample code (albeit with a single DB) in the readme-backbone.js app I'm building at Couchbase.
Hopefully the two libraries are similar enough that porting your code won't be hard.
For your inbox question:
The first concern is actually your MapReduce Views--they only deal with the documents in a single database. If you'll be using a View to access data based on channels, dates, users, etc, then you'll need all the documents within a single database. However, you could split the database on something "bigger" than per-user (like per-channel).
Hope that helps.

Related

Which way to go when setting up a database for my server

I'm developing a websocket real time browser game ( socketio nodejs) and wanted to start implementing my database and would like to know which type of database (nosql, sql .. ) would fit my situation best.
A small description of how i intend to use it :
I want to have game rooms with all their options stored ( which can be changed frequently)
a list of the connected users and their linked accounts( if a user is a guest he won't have a linked account, however if he does it would be linked with another table containing some extra data like lvl or something like that)
a list of user thema they like ( so for example when a game starts, it will take the themas in common for all users to use the game) all typical themas are stored in another big table that has a lot of data that won't be updated in a while.
So basically I have some tables that need a lot of quick and concurrent access which get updated and deleted frequently and some that don't need it and have a lot of permanent data.
I was thinking about using mongodb but honestly don't want to commit on something i don't have experience with ( i do have sql knowledge). I need suggestions thanks
TD;LR: I would personally go with PostgreSQL.
Recently, I had the same question as you, but with the only difference, I was not looking to build game rooms. After some research, I was convinced that PostgreSQL is awesome and suitable for every project. Well, tech giants use it too, including Facebook, Uber, Netflix... (https://stackshare.io/postgresql). It is scalable, easy to set one DB up, great community with lots of tutorials (both videos and articles) and it is also extensible, as it supports JSON, which is great!
You can use a great ORM for Node.js, such as TypeORM or Sequelize. Furthermore, I suggest you take a look at GraphQL, an API that has subscriptions (real-time operations). As I guess it will be a web application, I highly recommend you to go with React.js for the front-end functionalities, which interact great with GraphQL & Node.js. Last but not least, lots of developers and companies use both MongoDB and PostgreSQL for different functionalities and purposes for each. For user's tables use PostgreSQL, for multiple "big" JSON objects use MongoDB.
I hope that helps and lets you understand what you want in a more clear way. Good luck with your project!

Store data on server without Database

I’m webGL engine developer (ThreeJS) in small company. We have some events in few weeks and my boss just told me that i have to make registration form as soon as possible, also one page should show names, lastnames and company of all registered members. Problem is that i’m very bad in databases and i have really small amount of time to re-learn it. How can i store registration data on Server without Database? I looked up on web and most instructions are unclear(because i’ve not worked on database before) and others are using localstorage (as far as i know its used for cacheing data)
What you're looking for is a flat file database system, try taffyDB it basically use Json to store its data or Papa parse that uses CSV files, you can easily edit with excel for example.
If you're really good with javascript you can consider using a real database after all,mongodb is a bit advance but still not as complicated as mysql or even sqlite.

Store data accessible to and editable for all users in JavaScript

Is this possible to do:
Create a (web) database where you can add data from a website either by writing to a file or another method.
Allow another user on the website to access this by reading from a file or another method.
If it is, I would like some information or code.
I Do not want to create an independent database because:
a) I just started learning html5 and javascript
b) I do not know how, or have the resources to (I think, I'm just a user on a shared system without sudo access)
OR
Would I have to use something like firebase: (https://www.firebase.com/docs/web/quickstart.html)?
If you have a Database , why would you need to write to a "file"?
What you really want is to create an application with a database. So search for tutorials, because there are hundreds available from google, in all web oriented languages you can imagine.
Or maybe you are looking for something like this?
IndexedDB API
IndexedDB is a transactional database system, like an SQL-based RDBMS. However, unlike SQL-based RDBMSes, which use fixed-column tables, IndexedDB is a JavaScript-based object-oriented database.

Search tool in Meteor JS

Im quite a newbie when it comes to DBs and search so please bear with me. Im trying to implement a search function in Meteor app.
Ive checked through atmosphere and chanced upon these 4 options.
Mattodem easy search
Search Source
Elastic search package on Atmosphere (heard this is dated)
Elastic big data package on Atmosphere
My needs are for a simple search, able to handle larger data sets that may have data nesting. For example a task, may have comments or links etc. (Full text and more than regex query will be good)
I read that for easy search, even with some form of elastic or Mongodb application, seems to be application only for a single Mongo collection?For example what if I wanted to search across
Dinosaurs = new Meteor.Collection('dinosaurs'); and
Mammals = new Meteor.Collection('mammals');?
Appreciate any advice on the pros and cons on the 4 options above? 1 seems relative easy to implement but I,m not sure what it means by using elastic engine here. If I were to implement elastic, how do I go about doing it in Meteor? And would it differ from implementing a Elasticsearch HTTP API?
Similarly for Search Source, it supports Elastic too here. Honestly I have no clue on the differences.
This github project demonstrates how to use Meteor with ElasticSearch (not Mongo) for search applications
https://github.com/hharnisc/meteor-elasticsearch-demo/tree/master/elasticsearch-demo/packages/elastic-collection
it basically links a field to a session variable which triggers search on elastic. results are stored in a mongo collection that is pushed to the client through the Meteor mechanics. These are much smaller than the dataset and therefore are quick to update.
As far as searching accross collections, this is a typical problem of database schema definition. If you need to do joins, a mongodb is not the best solution. and relational DB like any SQL DB would be better suited, However, you should be looking into 'denormalization' of your data to see if you can create a structure that will work well for your use case.
This article explains what this means pretty well:
http://blog.mongodb.org/post/87892923503/6-rules-of-thumb-for-mongodb-schema-design-part-2
Good luck.

The concept of creating a news feed

I am currently using meteor.js for a social networking application that I am building. Currently I am struggling to find the best way to design a newsfeed for my users. Users are able to follow each other and create posts that should theoretically go to their followers. I have come up with two possible concepts that would work theoretically.
I. When a users makes a post the post goes into the global database which every user is subscribed and listening to, and whenever a post is added the user checks to see if the parent if they are following the parent of the post, and if they are they display it onto their newsfeed.
This way seems horribly inefficient, but it is a way.
II. The other way would be for each user to have their own little "hub" or each user would just subscribe to and listen for change in the user's hub.
This way seems better but I would have to do a for-loop on startup and subscribe to each user manually. Which may cause a slight delay on startup.
I am thinking that option two will work best, but I am wondering if anyone has any suggestions on how to accomplish this task. Or if there is a standard way to go about this. Thanks.
Look at the reywood:publish-composite package. I'm doing something similar in my app and am using this package to essentially perform a join. In your case people are following people so when creating a publication that returns the set of users that a person is following you can at the same time return the union of all their posts.
Building scalable feed technology is quite a hard problem to solve. With Meteor it is even harder because MongoDB doesn't lend itself very well for the storage of relational data, since it is a non-relational database, and creating publications that publish 'joined' data isn't straightforward. A lot of articles have been written about the problem of building scalable feed technology, have you seen my article on using Meteor in combination with Stream to build a solution that fits your needs?
Another route would be to use an open-source framework to create the backend for your feed technology. Have a look at Stream-Framework, the repositories README also has a great list of resources on building scalable feed technology.

Categories

Resources