Closed jum-s closed 7 years ago
everything is in this file, so far a mocked user is the answer but i would like to create this findOneByUsername
findOneByUsername: function (username) {
// Fake user
const wannabeUser = {
journal: 'bcf4f3ff325d7c8c7a5f67320e01a3f0',
data:
{ name: 'moleculor',
email: 'vincent.jumeaux@riseup.net',
provider: 'https://lab.allmende.io/u/moleculor' },
author: 'Douglas Adams',
description: 'Have fun, and thanks for all the fish!',
context: 'version',
timestamp: 1504438602552
}
if (wannabeUser.data.name == username) {
_.success(wannabeUser.data.name, 'existing user')
return promises_.resolve(wannabeUser)
} else {
_.error('user not found')
// not returning an Error object as it triggers a 500 response
return promises_.reject(wannabeUser)
}
}
there is no trace of a users
CouchDB database being initialized in db/init.js dbsList
: it could be simply something like { name: 'users', designDocs: [ 'users' ] }
.
Then couchInit will be looking for the file db/design_docs/users.json
that you need to create.
See CouchDB Design docs documentation, but read only about views, the other functions - reduce, re-reduce, list, show - aren't much needed (the last two being mostly legacy).
You can take inspiration on the existing journals design doc or inventaire's own users design doc.
great answer thx
A user type is created. Posting a new user through
breq.post(CONFIG.server.url() + '/user', newUser)
is working. But how to look for a user thing that has the name "foo" ? Is it possible with those methods in build_lib My best try without documentation was something likedb.viewByKey('byAttributes',['user', 'name'])