fs02 / grimoire Goto Github PK
View Code? Open in Web Editor NEWDatabase access layer for golang
Home Page: https://fs02.github.io/grimoire
License: MIT License
Database access layer for golang
Home Page: https://fs02.github.io/grimoire
License: MIT License
Thanks guys for sharing this package, very intuitive api in most cases with exception for relationships...
More of the question than issue I hope:
So I have relationship one to many:
Tests Table:
CREATE TABLE tests (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Tags Table:
CREATE TABLE tags (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
test_id INT UNSIGNED,
title TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (test_id)
REFERENCES tests(id)
ON DELETE CASCADE
);
Here are the structs:
type Test struct {
ID int
Title string
Tags []Tag `references:"ID" foreign_key:"TestID"`
CreatedAt string
UpdatedAt string
}
type Tag struct {
ID int
TestID int
Title string
CreatedAt string
UpdatedAt string
}
My question is how do I query all the tests with all assosiated tags. I tried all posibilities and I can not figure it out how to query relationships. Always geting null for the tags... Any help would be appriciated.
{
"status": "OK",
"data": [
{
"ID": 1,
"Title": "test 1",
"Tags": null,
"CreatedAt": "2019-08-19 23:18:24",
"UpdatedAt": "2019-08-19 23:18:24"
},
{
"ID": 1,
"Title": "test 1",
"Tags": null,
"CreatedAt": "2019-08-19 23:18:24",
"UpdatedAt": "2019-08-19 23:18:24"
},
{
"ID": 1,
"Title": "test 1",
"Tags": null,
"CreatedAt": "2019-08-19 23:18:24",
"UpdatedAt": "2019-08-19 23:18:24"
},
etc.
Hello,
I would like to say thank you for helping out last time. Unfortunetly I got stuck again.
I am trying to query many to many realtionship.
id
title
id
post_id
tag_id
Tables in the db are named as: posts, post_tag and tags. As far, this naming convention was working great for preloading has many, has one or belongs to. Can't figure it out how do I query posts with all the tags. Tried joins with preload but always get a panic mentioning that PostID or TagID field is not found...
ValidateRequired doesn't produce error even though required field is empty
https://play.golang.org/p/9soJDMn9B8t
ch.Errors()
should be [ktp_direksi is required, tdp is required, sk_domisili is required, akta_pendirian is required, akta_perubahan is required]
ch.Errors()
is []
(empty)
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.