go-rel / rel

:gem: Modern ORM for Golang - Testable, Extendable and Crafted Into a Clean and Elegant API

Home Page:https://go-rel.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support virtual field

hxgdzyuyi opened this issue · comments

In ecto :

schemas can also have virtual fields by passing the virtual: true option. These fields are not persisted to the database and can optionally not be type checked by declaring type :any.

Whether similar features can be provided ?

func TestDocument_Fields(t *testing.T) {
	var (
		record = struct {
			A string
			B *int
			C []byte     `db:",primary"`
			D bool       `db:"D"`
			E []*float64 `db:"-"`
		}{}
		doc    = NewDocument(&record)
		fields = []string{"a", "b", "c", "D"}
	)

	assert.Equal(t, fields, doc.Fields())
}

it works.