-
Notifications
You must be signed in to change notification settings - Fork 1
Breeds and species closes #21 #23
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
|
||
module.exports = function (app) { | ||
const mongooseClient = app.get('mongooseClient'); | ||
const { Schema } = mongooseClient; | ||
const breeds = new Schema({ | ||
displayName: { | ||
type: String, | ||
required: true | ||
}, | ||
default: { | ||
type: Boolean, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have some kind of restriction so that only one can be default? I don't know if Mongo (of sql!) has something like this. I'm thinking about Updates too, if another breed is selected as default, the previous default should be changed to false. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we need to do that later. Im gonna create an issue for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
default: false, | ||
required: true | ||
} | ||
}, { | ||
collection: 'breeds', | ||
versionKey: false, | ||
timestamp: true | ||
}); | ||
|
||
return mongooseClient.model('breeds', breeds); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
|
||
module.exports = function (app) { | ||
const mongooseClient = app.get('mongooseClient'); | ||
const { Schema } = mongooseClient; | ||
const species = new Schema({ | ||
displayName: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have an ID for breed and species or am I being to relational-SQL style? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has an autogenerated id |
||
type: String, | ||
required: true | ||
}, | ||
default: { | ||
type: Boolean, | ||
default: false, | ||
required: true | ||
} | ||
}, { | ||
collection: 'species', | ||
versionKey: false, | ||
timestamp: true | ||
}); | ||
|
||
return mongooseClient.model('species', species); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const local = require('@feathersjs/authentication-local'); | ||
const { authenticate } = require('@feathersjs/authentication').hooks; | ||
|
||
module.exports = { | ||
before: { | ||
all: [ | ||
// authenticate('jwt') | ||
], | ||
find: [], | ||
get: [], | ||
create: [ | ||
// local.hooks.hashPassword() | ||
], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
after: { | ||
all: [ | ||
// local.hooks.protect('password') | ||
], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
error: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
|
||
// Initializes the `Breed` service on path `/breeds` | ||
const createService = require('feathers-mongoose'); | ||
const createModel = require('../../models/breeds.model'); | ||
const hooks = require('./breeds.hooks'); | ||
const m2s = require('mongoose-to-swagger'); | ||
|
||
module.exports = function (app) { | ||
const Model = createModel(app); | ||
const paginate = app.get('paginate'); | ||
|
||
const options = { | ||
Model, | ||
paginate | ||
}; | ||
|
||
const service = createService(options); | ||
|
||
service.docs = { | ||
description: 'A service to manage breeds', | ||
definitions: { | ||
breeds: m2s(Model) | ||
}, | ||
'breeds list': { | ||
type: 'array', | ||
items: { $ref: '#definitions/breeds' } | ||
} | ||
}; | ||
|
||
app.use('/breeds', service); | ||
app.service('breeds').hooks(hooks); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const local = require('@feathersjs/authentication-local'); | ||
const { authenticate } = require('@feathersjs/authentication').hooks; | ||
|
||
module.exports = { | ||
before: { | ||
all: [ | ||
// authenticate('jwt') | ||
], | ||
find: [], | ||
get: [], | ||
create: [ | ||
// local.hooks.hashPassword() | ||
], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
after: { | ||
all: [ | ||
// local.hooks.protect('password') | ||
], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
error: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
|
||
// Initializes the `Species` service on path `/species` | ||
const createService = require('feathers-mongoose'); | ||
const createModel = require('../../models/species.model'); | ||
const hooks = require('./species.hooks'); | ||
const m2s = require('mongoose-to-swagger'); | ||
|
||
module.exports = function (app) { | ||
const Model = createModel(app); | ||
const paginate = app.get('paginate'); | ||
|
||
const options = { | ||
Model, | ||
paginate | ||
}; | ||
|
||
const service = createService(options); | ||
|
||
service.docs = { | ||
description: 'A service to manage species', | ||
definitions: { | ||
species: m2s(Model) | ||
}, | ||
'species list': { | ||
type: 'array', | ||
items: { $ref: '#definitions/species' } | ||
} | ||
}; | ||
|
||
app.use('/species', service); | ||
app.service('species').hooks(hooks); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Race is a different, quite uglier concept 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already changed that, its not race anymore.