Comments (10)
my quote:
please show me a way :)
this is a way "for me" how to handle features thats not implemented in kivik ! thank you very much :)
from kivik.
Kivik does not currently support user manipulation (adding, updating, or deleting users). I have always handled this through the management interface (Fauxton, etc). But it's probably a good idea to add support to Kivik, too.
from kivik.
@flimzy How do you handle features they are not supported in kivik? maybe like this? in very plain style?
type User struct {
Name string `json:"name"`
Password string `json:"password"`
Roles []interface{} `json:"roles"`
Type string `json:"type"`
}
data := User{
// fill struct
}
userBytes, err := json.Marshal(data)
if err != nil {
// handle err
}
body := bytes.NewReader(userBytes)
req, err := http.NewRequest("PUT", "http://localhost:5984/_users/org.couchdb.user"+data.Name, body)
if err != nil {
// handle err
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
// handle err
}
defer resp.Body.Close()
from kivik.
Yes, that's a reasonable approach as a stop-gap, until I have time to add user management to Kivik. :) I'll try to get around to adding that soon, but it may be a week or two before I have time.
from kivik.
@flimzy ok thank you. Let me know when it implemented :)
from kivik.
Please forgive my hasty response earlier; adding a standard user is quite possible with Kivik, as users are stored as standard documents. It is creation of admin users which is not currently possible.
For your use case, just do something like this:
client, _ := kivik.New(context.TODO(), "couch", "http://localhost:5984/")
usersDB, _ := client.DB(context.TODO(), "_users")
user := map[string]interface{}{
"_id": kivik.UserPrefix + "username",
"type": "user",
"password": "abc123",
}
_, _ = usersDB.Put(context.TODO(), kivik.UserPrefix+"username", user)
from kivik.
Sorry it took me a while to catch up... I guess I was sleeping when I responded yesterday. :)
I'll add this example to the wiki before I close this issue.
from kivik.
Sorry it took me a while to catch up... I guess I was sleeping when I responded yesterday. :)
lol
I'll add this example to the wiki before I close this issue.
I think this will help many developers. Your example is very useful for many cases. Its reduce my example to few lines of code :)
from kivik.
The wiki is now updated.
from kivik.
thanks.
from kivik.
Related Issues (20)
- Convert Replicate() options, and callback, to functional options
- Fix flaky tests
- Tests fail with go rc
- Remove the driver.OldGetter interface
- Kivik needs to zero the *driver.Row value before calling Next()
- Drop use of gopkg.in/yaml.v2
- Inconsistent error responses in tests
- Calling `kivik` with no arguments produces no output
- cmd/kivik: Add clean shutdown of kivik command on SIGINT/SIGTERM
- Make Attachments() return an error when there are no attachments
- Replace variable errors with constants
- Remove makeReady functionality
- Create an AttachmentsIterator wrappera round kivik.Attachments HOT 1
- cmd/kivik: Add `serve` command to serve CouchDB resources via HTTP from memorydb, fsdb, or couchdb proxy
- AllDocs fails with unexpected EOF HOT 6
- DBUpdates does not have any way to report the last seq id if there are no reported updates
- couchdb: DBUpdates only supports continuous mode
- Make DBUpdates use CouchDB defaults
- couchdb: CreateDB with options causes panic HOT 4
- 403 Target Service not allowed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kivik.