Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Side by Side Diff: service/rawdatastore/interface.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package rawdatastore
6
7 import (
8 "fmt"
9
10 "golang.org/x/net/context"
11 )
12
13 /// Kinds + Keys
14
15 // Key is the equivalent of *datastore.Key from the original SDK, except that
16 // it can have multiple implementations. See helper.Key* methods for missing
17 // methods like KeyIncomplete (and some new ones like KeyValid).
18 type Key interface {
19 Kind() string
20 StringID() string
21 IntID() int64
22 Parent() Key
23 AppID() string
24 Namespace() string
25
26 String() string
27 }
28
29 // KeyTok is a single token from a multi-part Key.
30 type KeyTok struct {
31 Kind string
32 IntID int64
33 StringID string
34 }
35
36 // Cursor wraps datastore.Cursor.
37 type Cursor interface {
38 fmt.Stringer
39 }
40
41 // Query wraps datastore.Query.
42 type Query interface {
43 Ancestor(ancestor Key) Query
44 Distinct() Query
45 End(c Cursor) Query
46 EventualConsistency() Query
47 Filter(filterStr string, value interface{}) Query
48 KeysOnly() Query
49 Limit(limit int) Query
50 Offset(offset int) Query
51 Order(fieldName string) Query
52 Project(fieldNames ...string) Query
53 Start(c Cursor) Query
54 }
55
56 // Iterator wraps datastore.Iterator.
57 type Iterator interface {
58 Cursor() (Cursor, error)
59 Next(dst PropertyLoadSaver) (Key, error)
60 }
61
62 // Interface implements the datastore functionality without any of the fancy
63 // reflection stuff. This is so that Filters can avoid doing lots of redundant
64 // reflection work. See helper.Datastore for a more user-friendly interface.
65 type Interface interface {
66 NewKey(kind, stringID string, intID int64, parent Key) Key
67 DecodeKey(encoded string) (Key, error)
68
69 NewQuery(kind string) Query
70 Count(q Query) (int, error)
71
72 RunInTransaction(f func(c context.Context) error, opts *TransactionOptio ns) error
73
74 Run(q Query) Iterator
75 GetAll(q Query, dst *[]PropertyMap) ([]Key, error)
76
77 Put(key Key, src PropertyLoadSaver) (Key, error)
78 Get(key Key, dst PropertyLoadSaver) error
79 Delete(key Key) error
80
81 // These allow you to read and write a multiple datastore objects in
82 // a non-atomic batch.
83 DeleteMulti(keys []Key) error
84 GetMulti(keys []Key, dst []PropertyLoadSaver) error
85 PutMulti(keys []Key, src []PropertyLoadSaver) ([]Key, error)
86 }
OLDNEW
« no previous file with comments | « service/rawdatastore/generic_key.go ('k') | service/rawdatastore/internal/protos/datastore/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698