UNPKG

@rnaga/wp-node

Version:

👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**

86 lines (85 loc) • 3.19 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var BlogsQuery_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlogsQuery = void 0; const component_1 = require("../decorators/component"); const alias_1 = require("./alias"); const meta_query_1 = require("./meta.query"); const query_builder_1 = require("./query-builder"); const query_builders_1 = require("./query-builders"); let BlogsQuery = BlogsQuery_1 = class BlogsQuery extends query_builder_1.QueryBuilder { alias; builders; builder; table = "blogs"; constructor(alias, builders, builder) { super(alias, builders, builder, BlogsQuery_1); this.alias = alias; this.builders = builders; this.builder = builder; } get from() { this.builder.table(this.alias.as("blogs")); return this; } get(b) { if (typeof b === "number") { this.where("blog_id", b); } else { this.where("domain", b); } this.builder.first(); return this; } select(columns) { this.builder.select(columns); return this; } withMeta(type = "right") { //this.replaceBuilder(this.metaQuery.joinPrimary(type).builder); const meta = this.builders.get(meta_query_1.MetaQuery, this.builder, this.alias); meta.setPrimaryTable("blog").from.joinPrimary(type); return this; } whereIn(column, values) { this.where(column, values); return this; } where(column, value, op = "=") { const { column: toColumn } = this.alias; if (Array.isArray(value)) { op = "in"; } this.builder.where(toColumn((column == "meta_key" || column == "meta_value" ? "blogmeta" : "blogs"), column), op, value); return this; } whereLike(column, value, options) { const { column: toColumn } = this.alias; if (options?.not === true) { this.builder.not; } this.builder.whereILike(toColumn("blogs", column), `%${value}%`); return this; } whereNotLike(column, value) { return this.whereLike(column, value, { not: true }); } }; exports.BlogsQuery = BlogsQuery; exports.BlogsQuery = BlogsQuery = BlogsQuery_1 = __decorate([ (0, component_1.queryBuilder)(), __metadata("design:paramtypes", [alias_1.Alias, query_builders_1.QueryBuilders, Object]) ], BlogsQuery);