0
bookshelf.js를 사용하고 있는데 데이터 형식 열을 변경하려고합니다.이 예가 제가 원하는 것입니다.Bookshelf 변경 열 데이터 형식
select * from table where date(datetime_col) = '2017-03-14'
datatime_col은 DATETIME이고 쿼리를 실행하려면 날짜로 변환하고 싶습니다.
이
내가이 어떻게 할 수있는 전체 예제이 미안이Error: ER_BAD_FIELD_ERROR: Unknown column 'date(datetime_col)' in 'where clause'
위의 코드를 실행하려고 오류가
var Model = new model().query(function (qb) {
qb.where('date(datetime_col)', '=' , date);
}).fetchAll()
책장에서 할 노력하고있어 어떻게 당신은 대답을 위해 감사를 위해 knex.raw와 bookshelf를 사용합니다. 사용 날짜 시간 열
var Model = new model().query(function (qb) {
qb.whereBetween(Bookshelf.knex.raw("DATE(colum_datetime)"), [date_var1, date_var2]);
}).fetchAll({ withRelated: ['table1', 'table2', {'table3':function (qb) {
qb.orderBy('date_column', 'desc')
}},'table4'] });
두 날짜 사이의 사용
곳
그것은 그 "bookshelf.js"또는 기본 "knex"의 속성 이름을 얻을 것으로 예상처럼 보이는var Model = new model().query("where", Bookshelf.knex.raw("DATE(colum_datetime)"), "=", date_var).fetchAll({ withRelated: ['table1', 'teble2', {'table3':function (qb) {
qb.orderBy('date_column', 'desc')
}},'table4'] });
고맙게도 작동합니다. –