Kamva/mgm

Get All from a collection

henri9813 opened this issue · 4 comments

Describe the bug

Syntax is wrong

result := []Book{}

err := mgm.Coll(&Book{}).SimpleFind(&result, bson.M{"age": bson.M{operator.Gt: 24}})

Should be:

result := []Book

err := mgm.Coll(&Book{}).SimpleFind(&result, bson.M{"age": bson.M{operator.Gt: 24}})

Or maybe i miss something ?

Additionnaly, maybe add the FindAll method example:

	var result []Book

	err := collection.SimpleFind(&result, bson.D{})

	log.Fatalf("here is the books: %v", result)

best regards

Golang does not support this syntax:

result := []Book

You should either create a new instance of a slice using make or declare it via literal.

result := make([]Book,0)
// or 
result2:=[]Book{}


FindAll example could be good but I think when developers learn how to search with query parameters, so they can guess how should they return all documents (empty query)

Hello,

I'm sorry, but golang support this syntax.

I'm currently using it

	var result []Book
	err := myCollection.SimpleFind(&result, bson.D{})

I agree with you for the documentation

Oh, wait, we don't do the same things.

In my case, i just declare the array without instanciate it.

You declare an empty array in your case.

My first message is wrong ...

I close the issue, sorry for the wasted time.