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

Getting Error does not implement DefaultValidate #6

Closed
ChStark opened this issue Feb 9, 2017 · 4 comments
Closed

Getting Error does not implement DefaultValidate #6

ChStark opened this issue Feb 9, 2017 · 4 comments
Labels

Comments

@ChStark
Copy link

ChStark commented Feb 9, 2017

Hi, I am new with golang and I tried to use your library and I get the following error

middlewares/main.go:76: cannot use model (type models.Model) as type mongodm.IDocumentBase in argument to ModelCollection.New:
	models.Model does not implement mongodm.IDocumentBase (DefaultValidate method has pointer receiver)

I have emmbeded the struct mongodm.DocumentBase on my definition, what is my problem ?

@moehlone
Copy link
Contributor

Hi,

could you send me some more details or (a part of) your project?

@ChStark
Copy link
Author

ChStark commented Feb 10, 2017

Is just a basic struct

type Model struct{
    mongodm.DocumentBase `json:",inline" bson:",inline"`
    ... some other fields
}

on the main :

connection.Register(&models.Model{}, "Models")

And I have a goroutine receiving the struct thru a channel:

func Routine() {
	for {
		model := <-ModelChannel
		ModelCollection := connection.Model("Model")
		ModelCollection.New(model)
	}
}

@uzarubin
Copy link
Contributor

uzarubin commented Feb 10, 2017

@ChStark Your model needs to take a pointer(*models.Model) from the ModelChannel

@moehlone
Copy link
Contributor

@ChStark do you need any more input after the answer of @uzarubin ?

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

No branches or pull requests

3 participants