OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "reflect" | 9 "reflect" |
10 | 10 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 // get parent | 269 // get parent |
270 par, _ := pls.GetMetaDefault("parent", nil).(*Key) | 270 par, _ := pls.GetMetaDefault("parent", nil).(*Key) |
271 | 271 |
272 return NewKey(aid, ns, kind, sid, iid, par), nil | 272 return NewKey(aid, ns, kind, sid, iid, par), nil |
273 } | 273 } |
274 | 274 |
275 func setKey(src interface{}, key *Key) { | 275 func setKey(src interface{}, key *Key) { |
276 pls := mkPLS(src) | 276 pls := mkPLS(src) |
277 if pls.SetMeta("key", key) == ErrMetaFieldUnset { | 277 if pls.SetMeta("key", key) == ErrMetaFieldUnset { |
278 » » lst := key.Last() | 278 » » lst := key.LastTok() |
279 if lst.StringID != "" { | 279 if lst.StringID != "" { |
280 _ = pls.SetMeta("id", lst.StringID) | 280 _ = pls.SetMeta("id", lst.StringID) |
281 } else { | 281 } else { |
282 _ = pls.SetMeta("id", lst.IntID) | 282 _ = pls.SetMeta("id", lst.IntID) |
283 } | 283 } |
284 _ = pls.SetMeta("kind", lst.Kind) | 284 _ = pls.SetMeta("kind", lst.Kind) |
285 _ = pls.SetMeta("parent", key.Parent()) | 285 _ = pls.SetMeta("parent", key.Parent()) |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 func mkPLS(o interface{}) PropertyLoadSaver { | 289 func mkPLS(o interface{}) PropertyLoadSaver { |
290 if pls, ok := o.(PropertyLoadSaver); ok { | 290 if pls, ok := o.(PropertyLoadSaver); ok { |
291 return pls | 291 return pls |
292 } | 292 } |
293 return GetPLS(o) | 293 return GetPLS(o) |
294 } | 294 } |
OLD | NEW |