entc/gen: add open func for creating client

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/44

Reviewed By: alexsn

Differential Revision: D17657719

fbshipit-source-id: 9bbe18dc0e9c553f8a2df81018d7db06f38f5e0e
This commit is contained in:
Ariel Mashraki
2019-10-02 01:39:14 -07:00
committed by Facebook Github Bot
parent 86a6fbe48e
commit cb1f78f233
35 changed files with 525 additions and 70 deletions

View File

@@ -0,0 +1,13 @@
{{/*
Copyright 2019-present Facebook Inc. All rights reserved.
This source code is licensed under the Apache 2.0 license found
in the LICENSE file in the root directory of this source tree.
*/}}
{{ define "dialect/sql/client/open" }}
drv, err := sql.Open(driverName, dataSourceName)
if err != nil {
return nil, err
}
return NewClient(append(options, Driver(drv))...), nil
{{ end }}