darrylkuhn / dialect Goto Github PK
View Code? Open in Web Editor NEWProvides JSON datatype support for the Eloquent ORM
License: MIT License
Provides JSON datatype support for the Eloquent ORM
License: MIT License
L5 eloquent models allows you to cast attributes:
protected $casts = [
'is_admin' => 'boolean',
'my_json_column' => 'array',
];
the idea is that your lib takes $casts
values so you don't need to declare $jsonColumns in models
How can I set data type as JSON
while creating migration?
I don't see anything in the code that is PostgreSQL specific. Not only that, but I'm using this w/ mysql :).
You might want to change the readme.
$product = Product::create(array(
'json_data' => array(...)
));
It doesn't work.
I was looking through the code, but I don't see what would require Ardent. Is that a mistake in the composer.json?
I have a problem installing on Laravel 5.1:
Your requirements could not be resolved to an installable set of packages.
Doesn't support Laravel 5.1?
That is without dropping down to raw sql.
Let's say I have table called employees, something like this:
CREATE TABLE employees
(
id serial NOT NULL,
name character varying(255) NOT NULL
)
With data like:
INSERT INTO employees (id, name) VALUES (1, 'john doe')
INSERT INTO employees (id, name) VALUES (2, 'john smith')
And a table called projects, something like this:
CREATE TABLE projects
(
id serial NOT NULL,
name character varying(255) NOT NULL,
employees jsonb NOT NULL
)
Where employees is an array of employee IDs. Something like:
INSERT INTO projects (name, employees) VALUES ('cool new project', '[{employee_id: 1}, {employee_id: 2}]')
Is there a way to define a many to many relation in a similar way to one to one relation that would automatically load something like this using Project::with('projectEmployees')->find(1);
;
{
"id": 1,
"name": "cool new project",
"employees": [
{"id": 1, "name" :"john doe"},
{"id": 2, "name": "john smith"}
]
}
So basically, I'm trying replace a separate pivot table by using JSON data instead in the hope to keep database structure more simple and to have more flexible way to define relationship in a more NoSQL fashion. Do tell me if this is a bad idea to begin with, since I'm pretty new to Postgres and JSON datatypes and I've only really worked with MySQL and MongoDB before.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.