@supabase/postgrest-js
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -1,1 +0,1 @@ | ||
"use strict";var _Request=_interopRequireDefault(require("./Request"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}var Builder=function(){function a(b){_classCallCheck(this,a),this.url=b,this.queryFilters=[]}return _createClass(a,[{key:"request",value:function request(a){return new _Request["default"](a,this.url)}},{key:"addFilters",value:function addFilters(a,b){0!=Object.keys(b).length&&Object.keys(b).forEach(function(c){var d=b[c];a.set(c,d)}),this.queryFilters.forEach(function(b){switch(b.filter){case"filter":a.filter(b.columnName,b.operator,b.criteria);break;case"match":a.match(b.query);break;case"order":a.order(b.property,b.ascending,b.nullsFirst);break;case"range":a.range(b.from,b.to);break;case"single":a.single();break;default:}})}},{key:"filter",value:function filter(a,b,c){return this.queryFilters.push({filter:"filter",columnName:a,operator:b,criteria:c}),this}},{key:"match",value:function match(a){return this.queryFilters.push({filter:"match",query:a}),this}},{key:"order",value:function order(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return this.queryFilters.push({filter:"order",property:a,ascending:b,nullsFirst:c}),this}},{key:"range",value:function range(a,b){return this.queryFilters.push({filter:"range",from:a,to:b}),this}},{key:"single",value:function single(){return this.queryFilters.push({filter:"single"}),this}},{key:"select",value:function select(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"*",b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=this.request("get");return c.select(a),this.addFilters(c,b),c}},{key:"insert",value:function insert(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=this.request("post");return Array.isArray(a)?(a.forEach(function(a){c.send(a)}),this.addFilters(c,b),c):{body:null,status:400,statusCode:400,statusText:"Data type should be an array."}}},{key:"update",value:function update(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=this.request("patch");return c.send(a),this.addFilters(c,b),c}},{key:"delete",value:function _delete(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=this.request("delete");return this.addFilters(b,a),b}}]),a}(),advancedFilters=["eq","gt","lt","gte","lte","like","ilike","is","in","not"];advancedFilters.forEach(function(a){return Builder.prototype[a]=function(b,c){return this.filter(b,a,c),this}});var _default=Builder;exports["default"]=_default; | ||
"use strict";var _Request=_interopRequireDefault(require("./Request"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}var Builder=function(){function a(b){_classCallCheck(this,a),this.url=b,this.queryFilters=[]}return _createClass(a,[{key:"request",value:function request(a){return new _Request["default"](a,this.url)}},{key:"addFilters",value:function addFilters(a,b){0!=Object.keys(b).length&&Object.keys(b).forEach(function(c){var d=b[c];a.set(c,d)}),this.queryFilters.forEach(function(b){switch(b.filter){case"filter":a.filter(b.columnName,b.operator,b.criteria);break;case"match":a.match(b.query);break;case"order":a.order(b.property,b.ascending,b.nullsFirst);break;case"range":a.range(b.from,b.to);break;case"single":a.single();break;default:}})}},{key:"filter",value:function filter(a,b,c){return this.queryFilters.push({filter:"filter",columnName:a,operator:b,criteria:c}),this}},{key:"match",value:function match(a){return this.queryFilters.push({filter:"match",query:a}),this}},{key:"order",value:function order(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return this.queryFilters.push({filter:"order",property:a,ascending:b,nullsFirst:c}),this}},{key:"range",value:function range(a,b){return this.queryFilters.push({filter:"range",from:a,to:b}),this}},{key:"single",value:function single(){return this.queryFilters.push({filter:"single"}),this}},{key:"select",value:function select(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"*",b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=this.request("GET");return c.select(a),this.addFilters(c,b),c}},{key:"insert",value:function insert(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=this.request("POST");return Array.isArray(a)?(a.forEach(function(a){c.send(a)}),this.addFilters(c,b),c):{body:null,status:400,statusCode:400,statusText:"Data type should be an array."}}},{key:"update",value:function update(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=this.request("PATCH");return c.send(a),this.addFilters(c,b),c}},{key:"delete",value:function _delete(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=this.request("DELETE");return this.addFilters(b,a),b}}]),a}(),advancedFilters=["eq","gt","lt","gte","lte","like","ilike","is","in","not"];advancedFilters.forEach(function(a){return Builder.prototype[a]=function(b,c){return this.filter(b,a,c),this}});var _default=Builder;exports["default"]=_default; |
{ | ||
"name": "@supabase/postgrest-js", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "PostgREST JS client", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -31,7 +31,3 @@ # Postgrest JS | ||
import { PostgrestClient } from ' @supabase/postgrest-js' | ||
// Point to your own PostgREST server (or use ours, but go easy..) | ||
const worldUrl = 'https://world.supabase.co/rest/v1' | ||
const queryParams = { apikey: 'public-key-bOYapLADERfE' } | ||
let client = new PostgrestClient(worldUrl, { queryParams }) | ||
let client = new PostgrestClient('https://your-postgrest.com') | ||
``` | ||
@@ -91,2 +87,3 @@ | ||
.match({ 'continent': 'Asia' }) | ||
.select('*') | ||
@@ -97,2 +94,3 @@ // Equal | ||
.eq('name', 'New Zealand') | ||
.select('*') | ||
@@ -103,2 +101,3 @@ // Greater than | ||
.gt('id', 20) | ||
.select('*') | ||
@@ -109,2 +108,3 @@ // Less than | ||
.lt('id', 20) | ||
.select('*') | ||
@@ -115,2 +115,3 @@ // Greater than or equal | ||
.gte('id', 20) | ||
.select('*') | ||
@@ -121,2 +122,3 @@ // Less than or equal | ||
.lte('id', 20) | ||
.select('*') | ||
@@ -127,2 +129,3 @@ // String search - case sensitive | ||
.like('name', '%Zeal%') | ||
.select('*') | ||
@@ -133,2 +136,3 @@ // String search - case insensitive | ||
.ilike('name', '%Zeal%') | ||
.select('*') | ||
@@ -139,2 +143,3 @@ // Exact equality (null, true, false) | ||
.is('name', null) | ||
.select('*') | ||
@@ -145,2 +150,3 @@ // In list | ||
.in('name', ['China', 'France']) | ||
.select('*') | ||
@@ -151,2 +157,3 @@ // Not equal | ||
.not('name', 'China') | ||
.select('*') | ||
@@ -153,0 +160,0 @@ ``` |
@@ -118,3 +118,3 @@ import Request from './Request' | ||
select(columnQuery = '*', options = {}) { | ||
let method = 'get' | ||
let method = 'GET' | ||
let request = this.request(method) | ||
@@ -132,3 +132,3 @@ | ||
insert(data, options = {}) { | ||
let method = 'post' | ||
let method = 'POST' | ||
let request = this.request(method) | ||
@@ -159,3 +159,3 @@ | ||
update(data, options = {}) { | ||
let method = 'patch' | ||
let method = 'PATCH' | ||
let request = this.request(method) | ||
@@ -174,3 +174,3 @@ | ||
delete(options = {}) { | ||
let method = 'delete' | ||
let method = 'DELETE' | ||
let request = this.request(method) | ||
@@ -177,0 +177,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
34132
208
0