Tag: 连帽衫

连帽衫 – 更新一个CouchDB文档(Node.js)

我正在使用Stripe处理费用和客户订阅,我想用这些处理作为连帽插件。 付款和客户的注册和订阅通常出现在Stripe Dashboard中,但我想要做的是更新CouchDB中的_users数据库,以确保客户的信息保存在某个地方。 我想要做的就是更新stripeCustomerId中的stripeCustomerId字段org.couchdb.user:user/bill document,从我的_users数据库中创build, _users数据库是用Hoodie进行login时创build的。 如果可能的话,创build这个字段,如果它不存在。 在连帽插件的文档中,更新函数对我来说似乎很模糊。 // update a document in db db.update(type, id, changed_attrs, callback) 我假设这个type是CouchDB文档中提到的type ,或者是我们用db.add(type, attrs, callback)添加文档时指定的db.add(type, attrs, callback) 。 id似乎是couchdb中的文档ID。 在我的情况下,它是org.couchdb.user:user/bill 。 但我不确定这是我应该通过我的更新function这个ID。 我认为changed_attrs是一个Javascript对象,其中有更新或新的属性,但在这里我再次怀疑。 所以我在我的worker.js试过这个: function handleCustomersCreate(originDb, task) { var customer = { card: task.card }; if (task.plan) { customer.plan = task.plan; } stripe.customers.create(customer, function(error, response) { var db […]