// Load loads the document in specified database.
Load loads the document in specified database.
// Load loads the document in specified database .
func Load(db *Database, docID string, obj interface{}) error {
	ptrValue := reflect.ValueOf(obj)
	if ptrValue.Kind() != reflect.Ptr || ptrValue.Elem().Kind() != reflect.Struct {
		return ErrNotStruct
	}
	if ptrValue.Elem().FieldByName("Document") == zero {
		return ErrNotDocumentEmbedded
	}
	doc, err := db.Get(docID, nil)
	if err != nil {
		return err
	}
	err = FromJSONCompatibleMap(obj, doc)
	if err != nil {
		return err
	}
	if id, ok := doc["_id"]; ok {
		setIDMethod := ptrValue.MethodByName("SetID")
		setIDMethod.Call([]reflect.Value{reflect.ValueOf(id)})
	}
	if rev, ok := doc["_rev"]; ok {
		setRevMethod := ptrValue.MethodByName("SetRev")
		setRevMethod.Call([]reflect.Value{reflect.ValueOf(rev)})
	}
	return nil
}
func Load ( db * Database , docID string , obj interface { } ) error { ptrValue := reflect . ValueOf ( obj ) if ptrValue . Kind ( ) != reflect . Ptr || ptrValue . Elem ( ) . Kind ( ) != reflect . Struct { return ErrNotStruct } if ptrValue . Elem ( ) . FieldByName ( " " ) == zero { return ErrNotDocumentEmbedded } doc , err := db . Get ( docID , nil ) if err != nil { return err } err = FromJSONCompatibleMap ( obj , doc ) if err != nil { return err } if id , ok := doc [ " " ] ; ok { setIDMethod := ptrValue . MethodByName ( " " ) setIDMethod . Call ( [ ] reflect . Value { reflect . ValueOf ( id ) } ) } if rev , ok := doc [ " " ] ; ok { setRevMethod := ptrValue . MethodByName ( " " ) setRevMethod . Call ( [ ] reflect . Value { reflect . ValueOf ( rev ) } ) } return nil }
Load loads the document in specified database.
Load loads the document in specified database .