ngorm / ngorm Goto Github PK
View Code? Open in Web Editor NEWNeo GORM: The modern fork of gorm The fantastic ORM( Object Relational Mapper ) for Go
License: MIT License
Neo GORM: The modern fork of gorm The fantastic ORM( Object Relational Mapper ) for Go
License: MIT License
The postgres support seems fine. For some reason I havent figured out yet to have dummy table in ql
tracking issue cznic/ql#155
Goa is a code generator that fully supports Gorm.
If you can match the postresql API then it would be great because I could use Ql on mobile and cockroaches on the server , whilst using the same code.
Probably worth putting a test with gomobile to check Ql works on android and iOS simulator.
Easiest was to test if to log to a cloud based log system like Google cloud .
Hello
I have problems to add an Index to a Model. Most likely I'm doing something wrong. I would appreciate an example of how to do it correctly.
I have found two issues:
Test
it can't create the the index statement, because it can't find the field deleted_at
WHERE
clauseThank you for your help and the awesome library.
Example:
package main
import (
"fmt"
"github.com/ngorm/ngorm"
"github.com/ngorm/ngorm/model"
_ "github.com/ngorm/ql"
)
type Test struct {
model.Model
Name string
Number int
}
func main() {
db, err := ngorm.Open("ql-mem", "test.db")
if err != nil {
panic(err)
}
expr, err := db.Begin().AutomigrateSQL(&Test{})
if err != nil {
panic(err)
}
fmt.Println(expr.Q)
expr, err = db.Model(&Test{}).AddIndexSQL("idx_test_number", "name", "number")
if err != nil {
panic(err)
}
fmt.Println(expr.Q)
}
Output:
BEGIN TRANSACTION;
CREATE TABLE tests (id int64,created_at time,updated_at time,deleted_at time,name string,number int ) ;
CREATE INDEX idx_tests_deleted_at ON tests(deleted_at);
COMMIT;
CREATE INDEX idx_test_number ON tests(name, number) WHERE deleted_at IS NULL
NGORM is not intending to be 100% API compatible with gorm. One aspect which ngorm emphasis is error handling. Errors must be handled, so any operation that might result into an error returns an error.
So, many functions should be familiar with gorm, it is just how they are implemented differs. So, this is the list of API for DB that must pe implemented by ngorm.
I discourage heavy use of chaining.Only when it is necessary to chain then chain.
DB.AddForeignKey
DB.AddIndex
DB.AddUniqueIndex
DB.Assign
DB.Association
DB.Attrs
DB.Automigrate
DB.CommonDB
DB.Count
DB.CreateTable
DB.Delete
DB.Dialect
DB.DropColumn
DB.DropTable
DB.DropTableIfExests
DB.Find
DB.First
DB.FirstOrCreate
DB.FirstOrInit
DB.Group
DB.HasTable
DB.Having
DB.Set
DB.Joins
DB.Last
DB.Limit
DB.Model
DB.ModifyColumn
DB.Not
DB.Offset
DB.Omit
DB.Or
DB.Order
DB.Pluck
DB.Preload
DB.Related
DB.RemoveIndex
DB.Save
DB.Select
DB.SingulatTable
DB.Table
DB.Update
DB.UpdateColumn
DB.UpdateColumns
DB.Updates
DB.Where
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.