Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmarshall error #16

Open
mriso79 opened this issue Mar 12, 2019 · 2 comments
Open

Unmarshall error #16

mriso79 opened this issue Mar 12, 2019 · 2 comments

Comments

@mriso79
Copy link

mriso79 commented Mar 12, 2019

Hi Rhino, I'm trying to make a query there, but I'm having an Unmarshall error, it displays my Struct keys but without the values ...

I made something like this:

type User struct {
	ID        string `json:"_id,omitempty"`
	Rev       string `json:"_rev,omitempty"`
	Name      string `json:"Name,omitempty"`
	Email     string `json:"Email,omitempty"`
	Password  string `json:"Password,omitempty"`
	Doctype   string `json:"Doctype,omitempty"`
	Birthday  string `json:"Birthday,omitempty"`
	CreatedAt string `json:"CreatedAt,omitempty"`
	UpdatedAt string `json:"UpdatedAt,omitempty"`
}

type ViewResult struct {
	Id  string `json:"id"`
	Key User   `json:"key"`
}

type ViewResponse struct {
	TotalRows int    `json:"total_rows"`
	Offset    int    `json:"offset"`
	Rows      []ViewResult  `json:"rows,omitempty"`
}

result := m.ViewResponse{}
	//now try to query the view
	err := db.GetView("users", "users", &result, nil)

Am I missing something? Thank you

@mriso79
Copy link
Author

mriso79 commented Mar 12, 2019

Hi There! I did it,

type ViewResult struct {
	Id  string    `json:"id"`
	Key string  `json:"key"`
        Value User `json:"value"`
}

It was missing the Value Parameter. I will let this documented here. Thx!

@rhinoman
Copy link
Owner

Glad it was something simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants