Commit 6b4faf90 authored by anton's avatar anton
Browse files

Change default timestamps and doc ids

parent 085f9c28
const
{ v4 } = require('uuid'),
constants = require('mbjs-data-models/src/constants'),
personSchema = require('./schema/person'),
bodySchema = require('./schema/body'),
......@@ -10,6 +11,11 @@ module.exports = function (app) {
const mongooseClient = app.get('mongooseClient')
const { Schema } = mongooseClient
const schema = new Schema({
_id: {
type: String,
default: () => `${constants.BASE_URI}annotations/${v4()}`,
alias: 'id'
},
'@context': {
type: String,
readOnly: true,
......@@ -38,7 +44,9 @@ module.exports = function (app) {
isSubdoument: true
})
}, {
timestamps: true
timestamps: true,
createdAt: 'created',
updatedAt: 'modified'
})
// This is necessary to avoid model compilation errors in watch mode
......
const
{ v4 } = require('uuid'),
constants = require('mbjs-data-models/src/constants'),
personSchema = require('./schema/person'),
stylesheetSchema = require('./schema/stylesheet'),
......@@ -9,6 +10,11 @@ module.exports = function (app) {
const { Schema } = mongooseClient
const schema = new Schema({
/** Document ID & ownership **/
_id: {
type: String,
default: () => `${constants.BASE_URI}maps/${v4()}`,
alias: 'id'
},
'@context': {
type: String,
readOnly: true,
......@@ -36,7 +42,9 @@ module.exports = function (app) {
isSubdoument: true
})
}, {
timestamps: true
timestamps: true,
createdAt: 'created',
updatedAt: 'modified'
})
// This is necessary to avoid model compilation errors in watch mode
......
// users-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
const
{ v4 } = require('uuid'),
constants = require('mbjs-data-models/src/constants')
module.exports = function (app) {
const modelName = 'users'
const mongooseClient = app.get('mongooseClient')
const schema = new mongooseClient.Schema({
_id: {
type: String,
default: () => `${constants.BASE_URI}users/${v4()}`,
alias: 'id'
},
email: { type: String, lowercase: true },
password: { type: String },
name: { type: String },
organization: { type: String },
user_id: { type: String, unique: true }
}, {
timestamps: true
timestamps: true,
createdAt: 'created',
updatedAt: 'modified'
})
// This is necessary to avoid model compilation errors in watch mode
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment