Hacker Newsnew | past | comments | ask | show | jobs | submit | aboutruby's favoriteslogin

The other answers have confirmed that Postgres will do this with array fields, and it's good advice to follow. It's also in my view much easier to read than MongoDB's query language is!

  CREATE TABLE documents (name text, tags text[]);
  INSERT INTO documents VALUES ('Doc1', '{tag1, tag2}');
  INSERT INTO documents VALUES ('Doc2', '{tag2, tag3}');
  INSERT INTO documents VALUES ('Doc3', '{tag2, tag3, tag4}');

  SELECT * FROM documents WHERE tags @> '{tag1}';
   name |    tags
  ------+-------------
   Doc1 | {tag1,tag2}
  
  SELECT * FROM documents WHERE tags @> '{tag2}';
   name |    tags
  ------+-------------
   Doc1 | {tag1,tag2}
   Doc2 | {tag2,tag3}
   Doc3 | {tag2,tag3,tag4}

  SELECT * FROM documents WHERE tags @> '{tag2, tag3}';
   name |       tags
  ------+------------------
   Doc2 | {tag2,tag3}
   Doc3 | {tag2,tag3,tag4}
Postgres certainly isn't perfect, but it's usually a good answer to "how do I store and query data" where you don't have any particular specialist requirements.

Great! This directly addresses one of the reasons I use Clang most of the time, and it's great to see that the GCC realizing that error message quality-of-life is important. As an aside:

  $ gcc-9 -c cve-2014-1266.c -Wall
  cve-2014-1266.c: In function ‘SSLVerifySignedServerKeyExchange’:
  cve-2014-1266.c:629:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
    629 |  if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
        |  ^~
  cve-2014-1266.c:631:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
    631 |   goto fail;
        |   ^~~~
this is a cute example ;)

Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: