Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
f02b286a
authored
2013-08-16 20:01:18 +0800
by
slene
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
orm make offset simple, can use any numeric type
1 parent
0372b817
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
orm/orm_queryset.go
orm/types.go
orm/orm_queryset.go
View file @
f02b286
...
...
@@ -2,6 +2,7 @@ package orm
import
(
"fmt"
"reflect"
)
type
querySet
struct
{
...
...
@@ -33,16 +34,28 @@ func (o querySet) Exclude(expr string, args ...interface{}) QuerySeter {
return
&
o
}
func
(
o
querySet
)
Limit
(
limit
int
,
args
...
int64
)
QuerySeter
{
func
(
o
*
querySet
)
setOffset
(
num
interface
{})
{
val
:=
reflect
.
ValueOf
(
num
)
switch
num
.
(
type
)
{
case
int
,
int8
,
int16
,
int32
,
int64
:
o
.
offset
=
val
.
Int
()
case
uint
,
uint8
,
uint16
,
uint32
,
uint64
:
o
.
offset
=
int64
(
val
.
Uint
())
default
:
panic
(
fmt
.
Errorf
(
"<QuerySeter> offset value need numeric not `%T`"
,
num
))
}
}
func
(
o
querySet
)
Limit
(
limit
int
,
args
...
interface
{})
QuerySeter
{
o
.
limit
=
limit
if
len
(
args
)
>
0
{
o
.
offset
=
args
[
0
]
o
.
setOffset
(
args
[
0
])
}
return
&
o
}
func
(
o
querySet
)
Offset
(
offset
int
64
)
QuerySeter
{
o
.
offset
=
offset
func
(
o
querySet
)
Offset
(
offset
int
erface
{}
)
QuerySeter
{
o
.
setOffset
(
offset
)
return
&
o
}
...
...
orm/types.go
View file @
f02b286
...
...
@@ -45,8 +45,8 @@ type QuerySeter interface {
Filter
(
string
,
...
interface
{})
QuerySeter
Exclude
(
string
,
...
interface
{})
QuerySeter
SetCond
(
*
Condition
)
QuerySeter
Limit
(
int
,
...
int
64
)
QuerySeter
Offset
(
int
64
)
QuerySeter
Limit
(
int
,
...
int
erface
{}
)
QuerySeter
Offset
(
int
erface
{}
)
QuerySeter
OrderBy
(
...
string
)
QuerySeter
RelatedSel
(
...
interface
{})
QuerySeter
Count
()
(
int64
,
error
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment