Skip to content

Instantly share code, notes, and snippets.

@pkej
Created July 17, 2018 07:14
Show Gist options
  • Save pkej/e0c2f34d351b7f2d40f8020063bde236 to your computer and use it in GitHub Desktop.
Save pkej/e0c2f34d351b7f2d40f8020063bde236 to your computer and use it in GitHub Desktop.
// Define the Feathers schema for service `users`. (Can be re-generated.)
// !code: imports // !end
// !code: init // !end
// Define the model using JSON-schema
let schema = {
// !code: schema_header
title: 'Users',
description: 'Users database.',
// !end
// !code: schema_definitions // !end
// Required fields.
required: [
// !code: schema_required
'email',
'username',
// !end
],
// Fields with unique values.
uniqueItemProperties: [
// !code: schema_unique // !end
],
// Fields in the model.
properties: {
// !code: schema_properties
id: { type: 'ID' },
username: {},
password: {},
email: {},
// !end
},
// !code: schema_more // !end
};
// Define optional, non-JSON-schema extensions.
let extensions = {
// GraphQL generation.
graphql: {
// !<DEFAULT> code: graphql_header
name: 'User',
service: {
sort: { id: 1 },
},
// sql: {
// sqlTable: 'Users',
// uniqueKey: 'id',
// sqlColumn: {
// __authorId__: '__author_id__',
// },
// },
// !end
discard: [
// !code: graphql_discard // !end
],
add: {
// !<DEFAULT> code: graphql_add
// __author__: { type: '__User__!', args: false, relation: { ourTable: '__authorId__', otherTable: 'id' } },
// !end
},
// !code: graphql_more // !end
},
};
// !code: more // !end
let moduleExports = {
schema,
extensions,
// !code: moduleExports // !end
};
// !code: exports // !end
module.exports = moduleExports;
// !code: funcs // !end
// !code: end // !end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment