コード例 #1
0
ファイル: document.go プロジェクト: yay-couch/couch-go
/**
 * TestSave
 */
func TestSave() {
	var doc = _document(
		"_id", "go_test_attc",
		"val1", "is val 1",
		"val2", "is val 2",
		"_attachments", []interface{}{
			couch.NewDocumentAttachment(nil, "./attc.txt", "attc1"),
			couch.NewDocumentAttachment(nil, "./attc.txt", "attc2"),
			map[string]interface{}{"file": "./attc.txt", "fileName": "attc3"},
		},
	)
	data, err := doc.Save(false, false)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Save >> %v", data)
	util.Dumpf("Document Save >> ok: %v", data["ok"])
	util.Dumpf("Document Save >> id: %v", data["id"])
	util.Dumpf("Document Save >> rev: %v", data["rev"])
}
コード例 #2
0
/**
 * TestRemove
 */
func TestRemove() {
	var doc = couch.NewDocument(Database,
		"_id", "attc_test",
		"_rev", "16-744735fac2c0bc49ff17f6a8fb8145bf",
	)
	var docAttc = couch.NewDocumentAttachment(doc, "./attc.txt", "attc2.txt")
	data, err := docAttc.Remove(false, false)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Attachment Remove >> %v", data)
	util.Dumpf("Document Attachment Remove >> ok: %v", data["ok"])
	util.Dumpf("Document Attachment Remove >> id: %s", data["id"])
	util.Dumpf("Document Attachment Remove >> rev: %s", data["rev"])
}
コード例 #3
0
/**
 * TestSave
 */
func TestSave() {
	var doc = couch.NewDocument(Database,
		"_id", "attc_test",
		"_rev", "15-521ec44a6b39f3c5b40b20f94408dd57",
	)
	var docAttc = couch.NewDocumentAttachment(doc, "./attc.txt", "attc2.txt")
	data, err := docAttc.Save()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Attachment Save >> %v", data)
	util.Dumpf("Document Attachment Save >> ok: %v", data["ok"])
	util.Dumpf("Document Attachment Save >> id: %s", data["id"])
	util.Dumpf("Document Attachment Save >> rev: %s", data["rev"])
}
コード例 #4
0
func _documentAttachment(file, fileName string) *couch.DocumentAttachment {
	return couch.NewDocumentAttachment(Document, file, fileName)
}