Comments (3)
Turns out that PostgreSQL has both array
& jsonb
data types that are PERFECT for this.
scema=> CREATE TABLE json_test (id SERIAL, text jsonb);
<?php
$stm = $pdo->prepare('INSERT INTO json_test (text) VALUES (:json)');
$stm->execute(['json' => $person]);
schema=> SELECT text->'name' AS name,
text->'address'->'addressLocality' AS city,
text->'address'->'addressRegion' AS state
FROM json_test WHERE text @> '{"@type": "Person", "worksFor": {"@type": "Organization", "name": "Super User Dev"}}';
name | city | state |
---|---|---|
"Christopher Wayne Zuber" | "Mount Vernon" | "WA" |
from schemaserver.
PostgreSQL: Documentation: 9.6: JSON Types
from schemaserver.
The solution will be to use text[]
& jsonb[]
, depending on if the values will be strings (or any simple value) or objects.
from schemaserver.
Related Issues (17)
- Add docs
- Implement saving objects/things HOT 3
- Finish creating common classes HOT 1
- Parse json & *[] from PostrgreSQL HOT 2
- Add validation for non-http URLS
- Change namespaces, etc. to organization
- Allow setting multiple values to a property HOT 2
- Should Geometry helper class be created? HOT 1
- Update database with new types of Things
- Finish implementing CreativeWork
- Save simple measurements? HOT 1
- Lint PHP files
- Add code owners
- Fix setting table when saving
- Missing tables in database
- Improve linting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schemaserver.