Skip to content

Instantly share code, notes, and snippets.

@gkielwasser
Created November 3, 2021 14:09
Show Gist options
  • Select an option

  • Save gkielwasser/d2758d2186c7c2ea16a1fdbac273843f to your computer and use it in GitHub Desktop.

Select an option

Save gkielwasser/d2758d2186c7c2ea16a1fdbac273843f to your computer and use it in GitHub Desktop.

Revisions

  1. gkielwasser created this gist Nov 3, 2021.
    3 changes: 3 additions & 0 deletions create-alias.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    client.aliases().upsert('warehouses', {
    'collection_name': 'dev-warehouses-v1.0.1-d'
    })
    53 changes: 53 additions & 0 deletions create-collection.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    client.collections().create({
    version: 'v1.0.1-d',
    alias: 'warehouses',
    name: 'dev-warehouses-v1.0.1-d',
    fields: [
    { name: 'id', type: 'string', facet: false },
    { name: 'name', type: 'string', facet: false },
    { name: 'location.geometry', type: 'geopoint', facet: false },
    {
    name: 'location.address.canton.id',
    type: 'string',
    facet: false
    },
    {
    name: 'location.address.canton.translations.fr-CH.translation',
    type: 'string',
    facet: true
    },
    {
    name: 'location.address.canton.translations.de-DE.translation',
    type: 'string',
    facet: true
    },
    {
    name: 'location.address.canton.translations.it-IT.translation',
    type: 'string',
    facet: true
    },
    {
    name: 'location.address.canton.translations.en-US.translation',
    type: 'string',
    facet: true
    },
    {
    name: 'craftsman.super_craftsman',
    type: 'bool',
    optional: true,
    facet: true
    },
    {
    name: 'craftsman.production_labels.*.*',
    type: 'string[]',
    optional: true,
    facet: true
    },
    {
    name: 'date_updated',
    type: 'int64',
    facet: false,
    _type: 'date'
    }
    ]
    })
    13 changes: 13 additions & 0 deletions index-document.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    client.collections('warehouses').documents().upsert({
    id: 'cf84f59d-c6a7-4160-ba57-f5aa2f11e03a',
    name: 'Hof Baumgarten',
    'location.geometry': [ 47.4823896, 7.6416678 ],
    'location.address.canton.id': '6f4bf1c2-c411-44fc-8800-f5fa990b9f8d',
    'location.address.canton.translations.fr-CH.translation': 'Soleure',
    'location.address.canton.translations.de-DE.translation': 'Solothurn',
    'location.address.canton.translations.it-IT.translation': 'Soletta',
    'location.address.canton.translations.en-US.translation': 'Solothurn',
    'craftsman.super_craftsman': false,
    'craftsman.production_labels.*.*': [ 'Natura-Veal' ],
    date_updated: 1635948200
    })