Skip to content

Is there any way to generate models without the crud methods on them? #181

@iuliananz

Description

@iuliananz

I want my clients to use a DAO to do anything DB related.
The only way to do that now, is to create another model, that's not DB specific and translate inside the DAO to that model and back.

If we'd have a template that generates the CRUD methods not linking them to the model, then I could use the generated models throughout the business layer without the risk that someone will use the Insert/Update methods on the actual model.

Is there a template to generate that, or is there a reason why you wouldn't support it, other than it wasn't yet done?

So, say I have a model FileTracker, currently it generates:

func (ft *FileTracker) Insert(ctx context.Context) *spanner.Mutation {
	values, _ := ft.columnsToValues(FileTrackerWritableColumns())
	return spanner.Insert("FileTracker", FileTrackerWritableColumns(), values)
}

I want it to generate this instead:

func Insert(ctx context.Context, ft *FileTracker) *spanner.Mutation {
	values, _ := ft.columnsToValues(FileTrackerWritableColumns())
	return spanner.Insert("FileTracker", FileTrackerWritableColumns(), values)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions