Last active
June 19, 2018 08:18
-
-
Save vongohren/e672da6d87143afe82837657df755d7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var User = Bookshelf.Model.extend({ | |
tableName: 'user', | |
hasTimestamps: true | |
}); | |
const to = (promise) => { | |
return promise.then(data => { | |
return [null, data]; | |
}) | |
.catch(err => [err]); | |
} | |
const getInfo = async (uuid) => { | |
const [err, userobj] = await to(User.forge({id:uuid}).fetch()) | |
if(err) throw new RepositoryError('UserModel failed finding one'); | |
return userobj | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
knex.schema.createTable('user', function(table) { | |
table.string('id').unique().primary(); | |
table.string('name').unique().primary(); | |
table.timestamp('created_at').notNullable().defaultTo(knex.fn.now()); | |
table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now()); | |
}) | |
const dids = [ | |
{ | |
'id':'f440e452-4af6-40db-b169-f05b24906026', | |
'context':'https://w3id.org/did/v1' | |
}, | |
{ | |
'id':'g230e452-8af6-90db-b169-f05b24906026', | |
'context':'https://w3id.org/did/v1' | |
}, | |
{ | |
'id':'k981t452-2af6-90db-b169-f05b24907801', | |
'context':'https://w3id.org/did/v1' | |
} | |
] | |
const seed = function(knex, Promise) { | |
console.log("DID seed") | |
return knex('user').insert(didData.dids); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment