couchdb

Hyperledger Fabric学习(七)智能合约(链码)

早过忘川 提交于 2020-08-11 11:12:39
智能合约(链码) 1、概述 链码的编写需要自定义struct,实现shim包Chaincode接口的两个方法: type Chaincode interface { Init ( stub ChaincodeStubInterface ) pb . Response Invoke ( stub ChaincodeStubInterface ) pb . Response } 链码的生命周期包括链码安装、实例化、升级等。其中链码的实例化和升级都会调用Init()方法,链码的invoke、query调用方式都只会调用Invoke()方法。 在shim包中,fabric给我们提供了ChaincodeStubInterface接口,在该接口中,我们可以使用接口中的方法实现具体的链码业务。 特别说明一句,如果链码方法最后返回的pb.Response是shim.Error(),那么所有的操作,包括数据插入、数据删除、创建复合键、发送事件、调用其他链码等都是无效的,即一次链码的调用具有事务性,如果返回shim.Success()则所有操作都成功,否则所有操作都失败。 2、接口描述 1)参数解析 直接获取所有参数 字节数组[]byte形式 /* args := stub.GetArgs() - args 所有参数的[]byte形式 */ GetArgs ( ) [ ] [ ] byte

整洁架构

北慕城南 提交于 2020-08-06 03:30:25
本文是关于Bob大叔关于整洁架构的一篇学习笔记。 前言 整洁架构(Clean Architecture)是由Bob大叔在2012年提出的一个架构模型,顾名思义,是为了使架构更简洁。 在开始深入的介绍这个架构之前,Bob大叔首先提到了 近些年来比较流行的一个系统架构,包括Hexagonal Architecture,Onion Architecture,以及他自己以前提出的Screaming architecuture等。并且着中说道通过这些架构产生的系统特点是: 独立的框架. 这样的架构并不依赖与应用软件的具体库包,这样可以将框架作为工具,而不必将你的系统都胡乱混合在一起。 可测试. 业务规则能够在没有UI和数据库 或Web服务器的情况下被测试。 UI的独立性. UI改变变得容易,不必改变系统的其余部分,一个Web UI能被一个控制台或专门的图形UI替代, 这些读不必更改业务核心规则。 数据库的独立性. 你能够在Oracle或SQL Server Mongo, BigTable, CouchDB,或之间切换, . 你的业务规则不会和数据库绑定 独立的外部代理,其实你的业务规则可以对其外面的技术世界毫无所知,比如是否使用了MVC或DCI都可以不关心。 好的,接下来一起了解一下clean architecture: 依赖规则(Dependency Rule)

CouchDB write-only database

荒凉一梦 提交于 2020-08-02 11:09:18
问题 I'm trying to setup a CouchDB database that could be publicly writable and only readable by the "admin" role. How can I do this. Is there a similar validate_doc_update function for accessing a document ? 回答1: One possible workaround would be to "abuse" Apache for this (though not 100% secure): You can use Apache to disallow GET from everyone except specific hosts which are the ones the admin uses... this way the users can write but can't read and the admin can read... You could even have

CouchDB write-only database

流过昼夜 提交于 2020-08-02 11:08:29
问题 I'm trying to setup a CouchDB database that could be publicly writable and only readable by the "admin" role. How can I do this. Is there a similar validate_doc_update function for accessing a document ? 回答1: One possible workaround would be to "abuse" Apache for this (though not 100% secure): You can use Apache to disallow GET from everyone except specific hosts which are the ones the admin uses... this way the users can write but can't read and the admin can read... You could even have

couchdb 2.0 installation error

拥有回忆 提交于 2020-07-09 07:32:21
问题 I'm trying to install couchdb2.0 on ubuntu server 14.04 following these guides: http://docs.couchdb.org/en/2.0.0/install/unix.html https://gist.github.com/SinanGabel/eac83a2f9d0ac64e2c9d4bd936be9313#file-couchdb-2-0-install-L33 the process starts but it keeps giving the following errors: couchdb@outland:/opt/couchdb/bin$ (./couchdb &) couchdb@outland:/opt/couchdb/bin$ [info] 2017-01-09T17:26:35.870856Z couchdb@localhost <0.9.0> -------- Application couch_log started on node couchdb@localhost

How to write a view in CouchDB to represent “not in” or “group by having count(*) = 1”?

柔情痞子 提交于 2020-06-29 04:04:34
问题 Using relational db as an example, given two tables like below, where when rows in tableA and tableB have the same values, they represent the same "thing" but in different "state". So for ID=1, this thing has gone through stage1 and 2. But for ID=2, this thing has only gone through stage1. tableA (Id, columnA, columnB) 1, "a", "b" 2, "x", "y" 3, "z", "a" tableB (Id, columnA, columnB) 1, "e", "f" I want to find all the rows from tableA that don't exist in tableB . select a.* from tableA a left

How to write a view in CouchDB to represent “not in” or “group by having count(*) = 1”?

爷,独闯天下 提交于 2020-06-29 04:04:20
问题 Using relational db as an example, given two tables like below, where when rows in tableA and tableB have the same values, they represent the same "thing" but in different "state". So for ID=1, this thing has gone through stage1 and 2. But for ID=2, this thing has only gone through stage1. tableA (Id, columnA, columnB) 1, "a", "b" 2, "x", "y" 3, "z", "a" tableB (Id, columnA, columnB) 1, "e", "f" I want to find all the rows from tableA that don't exist in tableB . select a.* from tableA a left

Change notification in CouchDB when a field is set

自闭症网瘾萝莉.ら 提交于 2020-06-24 07:49:25
问题 I'm trying to get notifications in a CouchDB change poll as soon as pre-defined field is set or changed. I've already had a look at filters that can be used for filtering change events( db/_changes?filter=myfilter ). However, I've not yet found a way to include this temporal information, because you can only get the current version of the document in this filter functions. Is there any possibility to create such a filter? If it does not work, I could export my field to a separate database and

Sorting CouchDB result by value

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-17 06:44:31
问题 I'm brand new to CouchDB (and NoSQL in general), and am creating a simple Node.js + express + nano app to get a feel for it. It's a simple collection of books with two fields, 'title' and 'author'. Example document: { "_id": "1223e03eade70ae11c9a3a20790001a9", "_rev": "2-2e54b7aa874059a9180ac357c2c78e99", "title": "The Art of War", "author": "Sun Tzu" } Reduce function: function(doc) { if (doc.title && doc.author) { emit(doc.title, doc.author); } } Since CouchDB sorts by key and supports a

PouchDB and Cookie Authentication with CouchDB not actually logging in the user

家住魔仙堡 提交于 2020-06-13 00:12:25
问题 I have a node app that uses CouchDB for the database and PouchDB on the client. To log in, a request is sent to the node server, which authenticates the user's credentials with the CouchDB instance, before sending a cookie back to the client. The issue is, after restarting the browser and logging in, CouchDB sends a 401 Unauthorized response when Pouch tries to connect to the DB, and the browser brings up its default login popup. This happens even though the AuthSession cookie is in the