couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodall <>
Subject Re: Best performing login implementation?
Date Mon, 06 Sep 2010 15:10:44 GMT
On 6 September 2010 15:18, Wout Mertens <> wrote:

> On Sep 6, 2010, at 15:39 , Tiago Freire wrote:
> > I am wondering about the best method for
> > implementing this.
> >
> > 1) Each username+login in a document.
> > 2) One document for username+logins, each one in a separate property.
> > {username:password}
> > 3) One document for username+logins, all in a single 'logins' array.
> > {logins: [{username:foo, password: bar}]}
> From general principle, 1) is the one you want. I haven't set up user auth
> myself, but in document-oriented databases you want to keep your data
> together in logical units that have a practical maximum size.
> So while, in a way, all your logins are a logical unit, there is no limit
> on how large that array will get so that is not a good way to store that
> information.
I'd go for one document per username+login. Don't be shy about throwing in
lots of other information about the user unless it really doesn't make sense
to store it in the same document for some reason. Your view can emit just
the username and password to keep the authentication request fast:

    function(doc) {
        if(doc.type == 'user') {
            emit(doc.username, doc.password);

The other thing to consider when designing your documents is who will be
updating them and how often. Ideally, you only want updates to come from one
person to avoid conflicts. If you put all username+password in a single
document then as the number of users grows you're increasingly likely to get
conflicts, e.g. whenever someone tries to change their password.

- Matt

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message