// Insert saves package into database.
Insert saves package into database.
// Insert saves package into database .
func (pkg *Package) Insert(ctx context.Context, db *sqlx.DB) error {
	now := helper.CurrentUTC()
	pkg.CreatedAt = now
	pkg.UpdatedAt = now
	query := `
INSERT INTO packages(domain_id, private, path, vcs, root, docs, description, homepage, license, created_at, updated_at)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`
	res, err := db.ExecContext(ctx, query, pkg.DomainID, pkg.Private, pkg.Path, pkg.VCS, pkg.Root, pkg.Docs, pkg.Description, pkg.Homepage, pkg.License, now, now)
	if err != nil {
		return err
	}
	pkg.ID, err = res.LastInsertId()
	if err != nil {
		return err
	}
	return nil
}
func ( pkg * Package ) Insert ( ctx context . Context , db * sqlx . DB ) error { now := helper . CurrentUTC ( ) pkg . CreatedAt = now pkg . UpdatedAt = now query := `
INSERT INTO packages(domain_id, private, path, vcs, root, docs, description, homepage, license, created_at, updated_at)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
` res , err := db . ExecContext ( ctx , query , pkg . DomainID , pkg . Private , pkg . Path , pkg . VCS , pkg . Root , pkg . Docs , pkg . Description , pkg . Homepage , pkg . License , now , now ) if err != nil { return err } pkg . ID , err = res . LastInsertId ( ) if err != nil { return err } return nil }
Insert saves package into database.
Insert saves package into database .