Skip to content

How implement struct for use in crud insert request? #320

Open

Description

How implement struct for put in crud request?

Example with map

	insert := crud.MakeInsertObjectRequest("user").
			Object(
				crud.MapObject(map[string]interface{}{
					"id":         userUUID,
					"created_at": time.Now().Unix(),
					"buc1ket_id": nil,
				})).
			Context(ctx)

But i want implement myself Object.

I should use this interface:

type encoder = msgpack.Encoder
type decoder = msgpack.Decoder

// Object is an interface to describe object for CRUD methods.
type Object interface {
	EncodeMsgpack(enc *encoder)
}

with private field encoder.

My struct

type Customer struct {
	ID        string `msgpack:"'id'"`
	CreatedAt string `msgpack:"'created_at'"`
	BucketID  *int64 `msgpack:"'bucket_id'"`
}

func (c *Customer) EncodeMsgpack(enc *msgpack.Encoder) {
	enc.Encode(&c)
}

What am i doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    1spdocumentationImprovements or additions to documentationteamE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions