2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[GAE/Datastore] エンティティのsliceプロパティを条件に検索する

Last updated at Posted at 2018-02-21

したいこと

こんな感じのArticleエンティティがデータストアに保存されてて、

type Article struct {
   Title string           `datastore:"Title"`
   Tags  []*datastore.Key `datastore:"Tags"`
}

keyのsliceプロパティに対して検索をかけたい!

参考

公式ドキュメント Datastore Reference 「Types and Property Classes」

Filterでいける

q := datastore.NewQuery("Article").Filter("Tags =", key)

対象slice内に指定した要素が存在すればOK」という基準で取ってくる。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?