pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21.37k stars 1.04k forks source link

Stay CouchDB-compliant #45

Closed iMoses closed 7 years ago

iMoses commented 7 years ago

Currently, when creating a collection the following logic determines the name of the database:

database.prefix + ':RxDB:' + name

This causes a problem when trying to use RxDB with CouchDB, since both uppercase letters and colons are illegal characters for a CouchDB database name.

An example of my use case, when trying to connect to a CouchDB host:

RxDB.create('http://127.0.0.1:5984/db_name', 'http')
    .then(db => db.collection('col_name', schema))

Receives the following response:

{
  "error": "illegal_database_name",
  "reason": "Name: 'db_name:RxDB:col_name'. Only lowercase characters (a-z), digits (0-9), and any of the characters _, $, (, ), +, -, and / are allowed. Must begin with a letter."
}

The solution here is simple, we can change :RxDB: to -rxdb-, but this will probably cause much damage to those who are already using the library.

Or am I misusing the library? :)

pubkey commented 7 years ago

Hi @iMoses There are currently no tests for the usage of the http-adapter. Therefore I didn't detect that it won't work. I will add the tests in the near future. Since we use semver, we can update the library without breaking existing systems. I will switch RxDB to version 3.x when the branch schemaMigration is ready. At this time I can change the prefix and also add some checks so it throws when people use an invalid collection-name.

pubkey commented 7 years ago

@iMoses Fixed with this commit. Since its a breaking change, it will be published in RxDB v3.0.0.