go.mercari.io/datastore@v1.8.2/boom/doc.go (about) 1 /* 2 Package boom handles the troublesome processing of datastore.Key automatically. 3 It calculates the Kind, ID, and Name from the name of struct and tags. 4 5 6 Key handling 7 8 boom beautifully maps keys and objects, making it easier to write code. 9 It is easier to collect information on one object than to treat Key and Entity separately. 10 Handling is very easy if Key has only ID or Name. 11 It just adds boom:"id" to the tag, as in the following code: 12 13 type Post struct { 14 ID int64 `datastore:"-" boom:"id"` 15 Content string 16 } 17 18 When Put the value of ID field is uses as the ID of Key, and when Get ID value of Key is set in ID field. 19 This allows you to break code to think or write about Key in your program. 20 21 Kind of Key is also calculated automatically. 22 By default, the name of the passed struct is the Kind name. 23 In the example of the previous code, 'Post' becomes Kind. 24 If you want to explicitly specify, boom:"kind" is given to the tag. 25 26 In the case of the following code, the Kind name will be 'pay' if there is no value in the Kind field. 27 If you have some value in the Kind field, that value will be the Kind name. 28 29 type Payment struct { 30 Kind string `datastore:"-" boom:"kind,pay"` 31 ID int64 `datastore:"-" boom:"id"` 32 Amount int 33 } 34 35 As for ParentKey, there is also a means to ease it. 36 boom:"parent" is given to the tag, field value is used as ParentKey. 37 38 39 For goon user 40 41 boom has a considerable API compatibility with goom. 42 43 There is a difference in behavior when Put under transaction. 44 Cloud Datastore does not assign the ID immediately before the Commit. 45 go.mercari.io/datastore following the Cloud Datastore specification will behave similarly even if the back end is AppEngine Datastore. 46 Therefore, if you need to use ID before Commit after Putting, you need to call AllocateID yourself beforehand. 47 48 Also, boom does not have any mechanism about the cache. 49 Because, it should be done with middleware on go.mercari.io/datastore. 50 Simple and nice, do not you? 51 */ 52 package boom // import "go.mercari.io/datastore/boom"