Skip to content

Instantly share code, notes, and snippets.

@djom202
Last active February 27, 2021 03:40
Show Gist options
  • Save djom202/55d1a0760bfa68a6e015fb5878bb6fcf to your computer and use it in GitHub Desktop.
Save djom202/55d1a0760bfa68a6e015fb5878bb6fcf to your computer and use it in GitHub Desktop.
Amplify Schema
// Vue methods
saveVehicle() {
this.$store.dispatch('vehicles/add_vehicle', this.newVehicle)
this.$store.dispatch('vehicles/set_newvehicleform', false)
},
// Store
async add_vehicle({ commit, dispatch }, payload) {
console.log('payload', payload)
try {
const resp = await DataStore.save(
new Vehicle({
enterpriseid: payload.enterprise.id,
enterprise: new Enterprise(payload.enterprise),
ownerid: payload.owner.sub,
owner: new Enterprise(payload.owner),
...payload
})
)
commit('add_vehicle_mutation', resp)
dispatch('set_vehicleselected', resp)
return resp
} catch (err) {
console.log('Error add_vehicle', err, payload)
return err
}
},
{
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
"gmodels": "amplify codegen models",
"serve-prod": "serve -s dist",
"build-dev": "vue-cli-service build --mode development",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@aws-amplify/core": "^3.8.9",
"@aws-amplify/datastore": "^2.9.3",
"@fortawesome/fontawesome-free": "^5.13.0",
"aws-amplify": "^3.3.14",
"register-service-worker": "^1.7.1",
"uiv": "^0.34.4",
"vue": "^2.6.11",
"vue-excel-editor": "^1.3.60",
"vue-google-charts": "^0.3.2",
"vue-gravatar": "^1.3.1",
"vue-moment": "^4.1.0",
"vue-number-animation": "^1.0.5",
"vue-qr-generator": "^3.0.1",
"vue-router": "^3.1.6",
"vue-select-image": "^1.9.0",
"vue-window-size": "^0.6.2",
"vue2-filters": "^0.11.0",
"vue2-google-maps": "^0.10.7",
"vuex": "^3.1.3",
"vuex-persistedstate": "^3.0.1"
},
"devDependencies": {
"@vue/cli-plugin-e2e-cypress": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-plugin-pwa": "~4.3.0",
"@vue/cli-plugin-router": "~4.3.0",
"@vue/cli-plugin-unit-mocha": "~4.3.0",
"@vue/cli-plugin-vuex": "~4.3.0",
"@vue/cli-service": "~4.3.0",
"@vue/eslint-config-airbnb": "^5.0.2",
"@vue/test-utils": "1.0.0-beta.31",
"chai": "^4.1.2",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.14.1",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
}
}
type S3Object {
bucket: String!
region: String!
key: String!
}
type Enterprise @model @auth(rules: [{ allow: public }]) {
id: ID!
owner: User @connection
vehicles: [Vehicle] @connection(keyName: "byEnterprise", fields: ["id"])
name: String!
key: String!
stared: Int!
state: Int!
}
type User @model @auth(rules: [{ allow: public }]) {
id: ID!
email: String!
email_verified: Boolean!
name: String!
ownVehicles: [Vehicle] @connection
driveVehicles: [UserVehicle] @connection(keyName: "byDrivers", fields: ["id"])
}
type UserVehicle
@model
@auth(rules: [{ allow: public }])
@key(name: "byDrivers", fields: ["userId", "vehicleId"])
@key(name: "byVehicles", fields: ["vehicleId", "userId"]) {
id: ID!
vehicleId: ID!
userId: ID!
vehicle: Vehicle! @connection(fields: ["vehicleId"])
user: User! @connection(fields: ["userId"])
state: Int!
}
type Vehicle
@model
@auth(rules: [{ allow: public }])
@key(name: "byEnterprise", fields: ["id"]) {
id: ID!
owner: User @connection
enterprise: Enterprise @connection
records: [ActivityHistory] @connection(keyName: "byVehicle", fields: ["id"])
geofences: [Geofence] @connection(keyName: "byVehicle", fields: ["id"])
drivers: [UserVehicle] @connection(keyName: "byVehicles", fields: ["id"])
plate: String!
model: String!
mark: String!
model_year: String!
country: String!
city: String!
service_type: Int!
gas_type: Int!
last_date_change_battery: String
reference_battery: String
km_last_change_battery: String
mark_battery: String
due_date_soat: String
value_last_soat: String
soat_insurer: String
due_date_techno: String
value_last_techno: String
last_techno_cda: String
lubricant_reference: String
lubricant_mark: String
last_date_change_lubricant: String
km_last_change_lubricant: String
tires_reference: String
tires_mark: String
state: Int!
hasGps: Int!
stared: Int!
}
type Activity @model @auth(rules: [{ allow: public }]) {
id: ID!
user: User @connection
enterprise: Enterprise @connection
title: String!
action: String!
weight: Int!
type: Int!
stared: Int!
state: Int!
}
type ActivityHistory
@model
@auth(rules: [{ allow: public }])
@key(name: "byVehicle", fields: ["id"]) {
id: ID!
activity: Activity @connection
vehicle: Vehicle @connection
user: User @connection
due_date: String
value: String
gallons: String
eds: String
kilometers: String
km_traveled: String!
km_ga: String!
price_km: String!
reference: String
brand: String
insurance: String
cda: String
units: String
warranty: String
entity: String
concept: String
pay_way: String
payment_type: Int!
files: [ActivityHistoryFiles] @connection
lng: Float
lat: Float
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
type ActivityHistoryFiles @model @auth(rules: [{ allow: public }]) {
id: ID!
activityHistoryId: ID!
url: S3Object! # or AWSURL
}
type Catalog @model @auth(rules: [{ allow: public }]) {
id: ID!
product_name: String!
datafield: String
cost: String!
image: String!
type: String!
state: Int!
}
type Notify @model @auth(rules: [{ allow: public }]) {
id: ID!
vehicle: Vehicle @connection
type: NotifyType @connection
description: String!
expired: Boolean!
}
type NotifyType @model @auth(rules: [{ allow: public }]) {
id: ID!
enterprise: Enterprise @connection
user: User @connection
title: String!
description: String!
}
type Redemption @model @auth(rules: [{ allow: public }]) {
id: ID!
user: User @connection
catalogue: Catalog @connection
cost: String!
points_before: String!
points_after: String!
details: String!
createdAt: String!
state: Int!
}
type Reminder @model @auth(rules: [{ allow: public }]) {
id: ID!
enterprise: Enterprise @connection
user: User @connection
title: String!
description: String!
timestamp: String!
}
type BatteryReference @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
state: Int!
}
type BatteryMark @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
state: Int!
}
type LubricantMark @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
state: Int!
}
type SoatReference @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
state: Int!
}
type SpareReference @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
type: Int!
state: Int!
}
type TireMark @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
state: Int!
}
type VehicleMark @model @auth(rules: [{ allow: public }]) {
id: ID!
name: String!
state: Int!
}
# Before called Gps
type Location @model @auth(rules: [{ allow: public }]) {
id: ID!
vehicle: Vehicle @connection
gps_time: String!
gps_date: String!
gps_lat: String!
gps_lon: String!
gps_alt: String!
gps_speed: String!
nav_distance: String!
battery_vol: String!
sensor_vol: String!
km_traveled: String!
performance: String!
}
type Geofence
@model
@auth(rules: [{ allow: public }])
@key(name: "byVehicle", fields: ["id"]) {
id: ID!
vehicle: Vehicle @connection
name: String!
lat: String!
lng: String!
ratio: String!
type: String!
color: String!
state: Int!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment