issue 101 - updating the data model
Added & removed many properties as required & fixed tests Updated & also cleaned up the fixtures, inc images Added order by published to the findPage query
This commit is contained in:
parent
e6f7c706cb
commit
60d90967e1
Binary file not shown.
Before Width: | Height: | Size: 46 KiB |
Binary file not shown.
Before Width: | Height: | Size: 70 KiB |
Binary file not shown.
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
Before Width: | Height: | Size: 77 KiB |
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
Before Width: | Height: | Size: 36 KiB |
File diff suppressed because one or more lines are too long
@ -16,25 +16,31 @@
|
||||
|
||||
knex.Schema.createTable('posts', function (t) {
|
||||
t.increments().primary();
|
||||
t.string('uuid');
|
||||
t.string('title');
|
||||
t.string('slug');
|
||||
t.text('content');
|
||||
t.text('content_html');
|
||||
t.string('meta_title');
|
||||
t.string('meta_description');
|
||||
t.string('meta_keywords');
|
||||
t.bool('featured');
|
||||
t.string('image');
|
||||
t.string('status');
|
||||
t.string('language');
|
||||
t.integer('author_id');
|
||||
t.date('created_at');
|
||||
t.integer('created_by');
|
||||
t.date('updated_at');
|
||||
t.integer('updated_by');
|
||||
t.date('published_at');
|
||||
t.integer('published_by');
|
||||
}),
|
||||
|
||||
knex.Schema.createTable('users', function (t) {
|
||||
t.increments().primary();
|
||||
t.string('username');
|
||||
t.string('first_name');
|
||||
t.string('last_name');
|
||||
t.string('uuid');
|
||||
t.string('full_name');
|
||||
t.string('password');
|
||||
t.string('email_address');
|
||||
t.string('profile_picture');
|
||||
@ -81,8 +87,10 @@
|
||||
|
||||
knex.Schema.createTable('settings', function (t) {
|
||||
t.increments().primary();
|
||||
t.string('uuid');
|
||||
t.string('key');
|
||||
t.text('value');
|
||||
t.string('type');
|
||||
t.date('created_at');
|
||||
t.integer('created_by');
|
||||
t.date('updated_at');
|
||||
@ -106,7 +114,6 @@
|
||||
};
|
||||
|
||||
down = function () {
|
||||
|
||||
return when.all([
|
||||
knex.Schema.dropTableIfExists("posts"),
|
||||
knex.Schema.dropTableIfExists("users"),
|
||||
|
@ -48,6 +48,10 @@
|
||||
|
||||
user: function () {
|
||||
return this.belongsTo(User, 'created_by');
|
||||
},
|
||||
|
||||
author: function () {
|
||||
return this.belongsTo(User, 'author_id');
|
||||
}
|
||||
|
||||
}, {
|
||||
@ -81,7 +85,8 @@
|
||||
page: 1,
|
||||
limit: 15,
|
||||
where: {},
|
||||
status: 'published'
|
||||
status: 'published',
|
||||
orderBy: 'published_at DESC'
|
||||
}, opts);
|
||||
|
||||
postCollection = Posts.forge();
|
||||
@ -105,7 +110,8 @@
|
||||
return postCollection
|
||||
.query('limit', opts.limit)
|
||||
.query('offset', opts.limit * (opts.page - 1))
|
||||
.fetch(_.omit(opts, 'page', 'limit', 'where', 'status'))
|
||||
.query('orderBy', opts.orderBy)
|
||||
.fetch(_.omit(opts, 'page', 'limit', 'where', 'status', 'orderBy'))
|
||||
.then(function (collection) {
|
||||
var qb;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
should.exist(found);
|
||||
|
||||
found.attributes.username.should.equal(firstUser.attributes.username);
|
||||
found.attributes.full_name.should.equal(firstUser.attributes.full_name);
|
||||
|
||||
done();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user