Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
timakin committed Aug 2, 2018
1 parent ebb57e2 commit 5b415ba
Show file tree
Hide file tree
Showing 7 changed files with 835 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# GoLand
.idea
88 changes: 88 additions & 0 deletions const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package dsmock

type TypeStyle string

const (
KeywordKey = "__key__"
KeywordCurrent = "__current__"
KeywordNoIndex = "__noindex__"
KeywordNoIndexValue = "noindex"

KeywordString = "__string__"
KeywordDatetime = "__datetime__"
KeywordInteger = "__integer__"
KeywordInt = "__int__"
KeywordFloat = "__float__"
KeywordBoolean = "__boolean__"
KeywordBool = "__bool__"
KeywordGeo = "__geo__"
KeywordArray = "__array__"
KeywordEmbed = "__embed__"
KeywordBlob = "__blob__"
KeywordNull = "__null__"
)

type DatastoreType string

const (
TypeString = DatastoreType("string")
TypeDatetime = DatastoreType("datetime")
TypeInteger = DatastoreType("integer")
TypeInt = DatastoreType("int")
TypeFloat = DatastoreType("float")
TypeBoolean = DatastoreType("boolean")
TypeBool = DatastoreType("bool")
TypeKey = DatastoreType("key")
TypeGeo = DatastoreType("geo")
TypeArray = DatastoreType("array")
TypeEmbed = DatastoreType("embed")
TypeBlob = DatastoreType("blob")
TypeNull = DatastoreType("null")
TypeNil = DatastoreType("<nil>")
)

var (
keywordTypeMap = map[string]DatastoreType{
KeywordString: TypeString,
KeywordDatetime: TypeDatetime,
KeywordInteger: TypeInteger,
KeywordInt: TypeInt,
KeywordFloat: TypeFloat,
KeywordBoolean: TypeBoolean,
KeywordBool: TypeBool,
KeywordKey: TypeKey,
KeywordGeo: TypeGeo,
KeywordArray: TypeArray,
KeywordEmbed: TypeEmbed,
KeywordBlob: TypeBlob,
KeywordNull: TypeNull,
}

typeKeywordMap = map[DatastoreType]string{
TypeString: KeywordString,
TypeDatetime: KeywordDatetime,
TypeInteger: KeywordInteger,
TypeInt: KeywordInt,
TypeFloat: KeywordFloat,
TypeBoolean: KeywordBoolean,
TypeBool: KeywordBool,
TypeKey: KeywordKey,
TypeGeo: KeywordGeo,
TypeArray: KeywordArray,
TypeEmbed: KeywordEmbed,
TypeBlob: KeywordBlob,
TypeNull: KeywordNull,
}
)

func IsKeyValueName(name string) bool {
return name == KeywordKey
}

func IsCurrentDatetime(name string) bool {
return name == KeywordCurrent
}

func IsNoIndex(value string) bool {
return value == KeywordNoIndexValue
}
11 changes: 11 additions & 0 deletions dsmock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dsmock

import "context"

func InsertMockData(ctx context.Context, filename string) error {
err := Upsert(ctx, filename)
if err != nil {
return err
}
return nil
}
Loading

0 comments on commit 5b415ba

Please sign in to comment.