-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
154 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2014 The zhgo Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package db | ||
|
||
import () | ||
|
||
// Condition struct | ||
type Condition struct { | ||
Eq map[string]string | ||
Ge map[string]string | ||
Gt map[string]string | ||
Le map[string]string | ||
Lt map[string]string | ||
Ne map[string]string | ||
Like map[string]string | ||
In map[string][]string | ||
} | ||
|
||
func (c *Condition) Success() { | ||
|
||
} | ||
|
||
// New condition | ||
func NewCondition() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2014 The zhgo Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package db | ||
|
||
import ( | ||
"database/sql" | ||
) | ||
|
||
// Alias of map[string]interface{} | ||
type Item map[string]interface{} | ||
|
||
// Alias of []map[string]interface{} | ||
type Items []map[string]interface{} | ||
|
||
// Alias of map[string]interface{} | ||
type Where map[string]interface{} | ||
|
||
// Enviroment: 0, 1, 2, 3 | ||
var Env int8 = 0 | ||
|
||
// Server instance | ||
var dbObjects map[string]*sql.DB = make(map[string]*sql.DB) | ||
|
||
// Server list | ||
var Servers = make(map[string]*Server) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2014 The zhgo Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package db | ||
|
||
import ( | ||
"reflect" | ||
) | ||
|
||
// Table struct | ||
type Table struct { | ||
// Table name | ||
Name string | ||
|
||
// Table primary | ||
Primary string | ||
|
||
// All fields, except primary | ||
Fields []string | ||
|
||
// All fields | ||
AllFields []string | ||
|
||
// Entity | ||
EntityType reflect.Type | ||
} | ||
|
||
// New Table | ||
func NewTable(tableName string, entity interface{}) Table { | ||
p, f, af := tableFields(entity) | ||
t := Table{ | ||
Name: tableName, | ||
Primary: p, | ||
Fields: f, | ||
AllFields: af, | ||
EntityType: reflect.ValueOf(entity).Elem().Type()} | ||
return t | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters