@electric-sql/pglite-postgis 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @electric-sql/pglite-postgis
|
|
2
|
+
|
|
3
|
+
*** EXPERIMENTAL ***
|
|
4
|
+
|
|
5
|
+
PostGIS extension for [PGlite](https://pglite.dev). This is an experimental release, use at your own risk.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @electric-sql/pglite-postgis
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { PGlite } from '@electric-sql/pglite'
|
|
17
|
+
import { postgis } from '@electric-sql/pglite-postgis'
|
|
18
|
+
|
|
19
|
+
const pg = new PGlite({
|
|
20
|
+
extensions: {
|
|
21
|
+
postgis,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
await pg.exec('CREATE EXTENSION IF NOT EXISTS postgis;')
|
|
26
|
+
|
|
27
|
+
// Create a table with geometry columns
|
|
28
|
+
await pg.exec(`
|
|
29
|
+
CREATE TABLE cities (
|
|
30
|
+
id SERIAL PRIMARY KEY,
|
|
31
|
+
name TEXT NOT NULL,
|
|
32
|
+
location GEOMETRY(Point, 4326)
|
|
33
|
+
);
|
|
34
|
+
`)
|
|
35
|
+
|
|
36
|
+
// Insert data
|
|
37
|
+
await pg.query(`
|
|
38
|
+
INSERT INTO cities (name, location)
|
|
39
|
+
VALUES ('New York', ST_GeomFromText('POINT(-74.0060 40.7128)', 4326))
|
|
40
|
+
`)
|
|
41
|
+
|
|
42
|
+
// Query with spatial functions
|
|
43
|
+
const result = await pg.query(`
|
|
44
|
+
SELECT name, ST_AsText(location) as location
|
|
45
|
+
FROM cities
|
|
46
|
+
`)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
Apache-2.0
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@electric-sql/pglite-postgis",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "PostGIS extension for PGlite",
|
|
5
|
+
"author": "Electric DB Limited",
|
|
6
|
+
"homepage": "https://pglite.dev",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"postgres",
|
|
10
|
+
"sql",
|
|
11
|
+
"database",
|
|
12
|
+
"wasm",
|
|
13
|
+
"pglite",
|
|
14
|
+
"postgis",
|
|
15
|
+
"gis",
|
|
16
|
+
"geospatial"
|
|
17
|
+
],
|
|
18
|
+
"private": false,
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/electric-sql/pglite.git",
|
|
44
|
+
"directory": "packages/pglite-postgis"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup && tsx scripts/bundle-wasm.ts",
|
|
48
|
+
"check:exports": "attw . --pack --profile node16",
|
|
49
|
+
"lint": "eslint ./src ./tests --report-unused-disable-directives --max-warnings 0",
|
|
50
|
+
"format": "prettier --write ./src ./tests",
|
|
51
|
+
"typecheck": "tsc",
|
|
52
|
+
"stylecheck": "pnpm lint && prettier --check ./src ./tests",
|
|
53
|
+
"test": "vitest",
|
|
54
|
+
"prepublishOnly": "pnpm check:exports"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@arethetypeswrong/cli": "^0.18.1",
|
|
58
|
+
"@electric-sql/pglite": "workspace:*",
|
|
59
|
+
"@types/node": "^20.16.11",
|
|
60
|
+
"vitest": "^2.1.2"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@electric-sql/pglite": "workspace:*"
|
|
64
|
+
}
|
|
65
|
+
}
|