mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
Added concept of ghost-query debug mode
- Outputting all queries is too much debug info for normal dev - Use DEBUG=ghost:*,ghost-query to debug queries - Or just DEBUG=ghost-query
This commit is contained in:
parent
9b54ed0689
commit
5319fd4e35
@ -1,4 +1,5 @@
|
||||
var debug = require('ghost-ignition').debug('models:plugin:include-count'),
|
||||
var _debug = require('ghost-ignition').debug._base,
|
||||
debug = _debug('ghost-query'),
|
||||
_ = require('lodash');
|
||||
|
||||
module.exports = function (Bookshelf) {
|
||||
@ -61,7 +62,11 @@ module.exports = function (Bookshelf) {
|
||||
fetch: function () {
|
||||
this.addCounts.apply(this, arguments);
|
||||
|
||||
debug('QUERY', this.query().toQuery());
|
||||
// Useful when debugging no. database queries, GQL, etc
|
||||
// To output this, use DEBUG=ghost:*,ghost-query
|
||||
if (_debug.enabled('ghost-query')) {
|
||||
debug('QUERY', this.query().toQuery());
|
||||
}
|
||||
|
||||
// Call parent fetch
|
||||
return modelProto.fetch.apply(this, arguments);
|
||||
@ -69,7 +74,11 @@ module.exports = function (Bookshelf) {
|
||||
fetchAll: function () {
|
||||
this.addCounts.apply(this, arguments);
|
||||
|
||||
debug('QUERY', this.query().toQuery());
|
||||
// Useful when debugging no. database queries, GQL, etc
|
||||
// To output this, use DEBUG=ghost:*,ghost-query
|
||||
if (_debug.enabled('ghost-query')) {
|
||||
debug('QUERY', this.query().toQuery());
|
||||
}
|
||||
|
||||
// Call parent fetchAll
|
||||
return modelProto.fetchAll.apply(this, arguments);
|
||||
|
Loading…
Reference in New Issue
Block a user