FAQ
Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

The project aims for developers friendly*, *so I think you will love it!

Check it out, https://github.com/jinzhu/gorm

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jesse McNelis at Oct 28, 2013 at 3:15 am

    On Mon, Oct 28, 2013 at 1:31 PM, Jinzhu Zhang wrote:
    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    All your examples and documentation completely ignore error handling.
    Error handling is an essential part of any API, by avoiding it in your
    examples you're encouraging your users not to do it and you're giving an
    untruthful example of how actual code must use your API.
    How do I handle errors in a chain? how do I match an error up to the call
    in that chain?
    What kind of errors can I expect?


    --
    =====================
    http://jessta.id.au

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jinzhu at Oct 28, 2013 at 3:28 am
    Sorry, the error handling is not documented even in the README.

    Here is how to handle errors:

    query := db.Where("name = ?", "jinzhu").First(&user)
    query := db.First(&user).Limit(10).Find(&users)
    // query.Error -> the last error happened (error)
    // query.Errors -> all errors happened ([]errors)
    // If an error happened, gorm will stop do insert, update, delete operations

    Just updated the online README, Thank you for pointing it out.




    On Mon, Oct 28, 2013 at 11:15 AM, Jesse McNelis wrote:
    On Mon, Oct 28, 2013 at 1:31 PM, Jinzhu Zhang wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    All your examples and documentation completely ignore error handling.
    Error handling is an essential part of any API, by avoiding it in your
    examples you're encouraging your users not to do it and you're giving an
    untruthful example of how actual code must use your API.
    How do I handle errors in a chain? how do I match an error up to the call
    in that chain?
    What kind of errors can I expect?


    --
    =====================
    http://jessta.id.au

    --
    Best regards

    ------------------------
    Jinzhu
    github.com/jinzhu

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jacek Furmankiewicz at Oct 28, 2013 at 4:54 pm
    You probably need to change the name.

    Whenever most folks here of GORM they will think of the Groovy/Grails ORM:

    http://grails.org/doc/latest/guide/GORM.html


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jinzhu Zhang at Oct 29, 2013 at 3:49 am
    Always hard to name a project, so just leave it. I don't want it is renamed
    to something like capistrano that I could never remember. ;)

    On Tuesday, October 29, 2013 12:54:48 AM UTC+8, Jacek Furmankiewicz wrote:

    You probably need to change the name.

    Whenever most folks here of GORM they will think of the Groovy/Grails ORM:

    http://grails.org/doc/latest/guide/GORM.html

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Kevin P at Oct 28, 2013 at 10:16 pm
    Very cool, can't wait to use it.
    On Sunday, October 27, 2013 10:31:25 PM UTC-4, Jinzhu Zhang wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jinzhu Zhang at Oct 29, 2013 at 3:50 am
    Just give it some updates, cooler now, hope you could enjoy it! ;)
    On Tuesday, October 29, 2013 6:15:57 AM UTC+8, Kevin P wrote:

    Very cool, can't wait to use it.
    On Sunday, October 27, 2013 10:31:25 PM UTC-4, Jinzhu Zhang wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Alang yin at Oct 29, 2013 at 6:33 am
    真棒。张金柱大神,又看到你的作品了。
    On Monday, October 28, 2013 10:31:25 AM UTC+8, Jinzhu wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jinzhu at Oct 30, 2013 at 2:07 am
    ;)
    On Tuesday, October 29, 2013 2:33:13 PM UTC+8, alang yin wrote:

    真棒。张金柱大神,又看到你的作品了。
    On Monday, October 28, 2013 10:31:25 AM UTC+8, Jinzhu wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Tomwilde at Oct 29, 2013 at 3:54 pm
    I don't intend to be mean but this is not what an ORM is; an ORM is an
    Object-Relation-Mapper. An ORM focuses on the relations between objects,
    abstracting CRUD away.

    Cool SQL wrapper, though.
    On Monday, October 28, 2013 3:31:25 AM UTC+1, Jinzhu wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jesse McNelis at Oct 29, 2013 at 11:12 pm

    On Wed, Oct 30, 2013 at 2:54 AM, tomwilde wrote:

    I don't intend to be mean but this is not what an ORM is; an ORM is an
    Object-Relation-Mapper. An ORM focuses on the relations between objects,
    abstracting CRUD away.
    Object-Relational-Mapper, it maps a relational database to objects which
    has nothing to do with the relationship between objects.
    There was a strange point a few years ago where everyone got confused about
    the word "relation" and thought it was about foreign keys instead of it's
    original meaning "a group of related values", eg. "record", "row", "struct".

    --
    =====================
    http://jessta.id.au

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jinzhu at Oct 30, 2013 at 2:04 am
    Yes, I think Jasse is right.

    But anyway, because relations are so common used when building a website,
    and this project aims for developer friendly.

    So definitely relationship between objects will be supported (Actually it
    is just my next todo item). ;)

    On Wednesday, October 30, 2013 7:12:22 AM UTC+8, Jesse McNelis wrote:

    On Wed, Oct 30, 2013 at 2:54 AM, tomwilde <sedevel...@gmail.com<javascript:>
    wrote:
    I don't intend to be mean but this is not what an ORM is; an ORM is an
    Object-Relation-Mapper. An ORM focuses on the relations between objects,
    abstracting CRUD away.
    Object-Relational-Mapper, it maps a relational database to objects which
    has nothing to do with the relationship between objects.
    There was a strange point a few years ago where everyone got confused
    about the word "relation" and thought it was about foreign keys instead of
    it's original meaning "a group of related values", eg. "record", "row",
    "struct".

    --
    =====================
    http://jessta.id.au
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jinzhu at Oct 30, 2013 at 3:12 am
    I am working on convert a website using hood as the ORM to gorm.

    The result is gorm works so great that I could simplify the code really a
    lot!

    Let's see the difference. ( http://play.golang.org/p/q_80PI-X9k )

    Old Code:

    func Find(id int64) (service Service, err error) {
         var services []Service
         err = DB.Where(“id”, “=”, int64(id)).Find(&services)
         if err == nil {
             if len(services) == 0 {
                 err = errors.New(“Service Not found”)
             } else {
                 service = services[0]
             }
         }
         return
    }

    func (payer *Payer) FindOrCreatePayerService(service_id int64) (ps
    PayerService, err error) {
         service, err := Find(service_id)
         if err == nil {
             var results []PayerService
             err = DB.Where(“payer_id”, “=”,
    int64(payer.Id)).Where(“service_id”, “=”, service_id).Find(&results)
             if err != nil {
                 return
             }
             if len(results) == 0 {
                 ps = PayerService{PayerId: payer.Id, ServiceId: service_id}
             } else {
                 ps = results[0]
             }
         }
         return
    }

    func (payer *Payer) AddService(service_id int64) (err error) {
         payer_service, err := payer.FindOrCreatePayerService(service_id)
         if err == nil {
             payer_service.State = “using”
             err = DB.Save(&payer_service)
         }
         return
    }



    New Code:

    func (payer *Payer) AddService(service_id int64) (err error) {
         err = DB.First(&service.Service{}, service_id).Error
         if err == nil {
             err = DB.Where(PayerService{PayerId: payer.Id, ServiceId:
    service_id}).FirstOrCreate(&PayerService{}).Update(“state”, “using”).Error
         }
         return
    }


    Really a big change, yes?
    On Wednesday, October 30, 2013 10:04:46 AM UTC+8, Jinzhu wrote:

    Yes, I think Jasse is right.

    But anyway, because relations are so common used when building a website,
    and this project aims for developer friendly.

    So definitely relationship between objects will be supported (Actually it
    is just my next todo item). ;)

    On Wednesday, October 30, 2013 7:12:22 AM UTC+8, Jesse McNelis wrote:
    On Wed, Oct 30, 2013 at 2:54 AM, tomwilde wrote:

    I don't intend to be mean but this is not what an ORM is; an ORM is an
    Object-Relation-Mapper. An ORM focuses on the relations between objects,
    abstracting CRUD away.
    Object-Relational-Mapper, it maps a relational database to objects which
    has nothing to do with the relationship between objects.
    There was a strange point a few years ago where everyone got confused
    about the word "relation" and thought it was about foreign keys instead of
    it's original meaning "a group of related values", eg. "record", "row",
    "struct".

    --
    =====================
    http://jessta.id.au
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rogerpack2005 at Jan 3, 2014 at 4:09 am

    On Sunday, October 27, 2013 8:31:25 PM UTC-6, Jinzhu wrote:

    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool
    Manual migrations might be a nice addition. AutoMigrate for instance can't
    change database column types in production :) (or can it do this already?)
    Thanks for the lib.
    -roger-

    >

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Philippe Lafoucrière at Jan 18, 2014 at 6:11 pm
    +1 for manual migrations too :)
    Otherwise, I think goose (https://bitbucket.org/liamstask/goose) can mixed
    with gorm.
    Anyway, it's the cleanest API I've seen so far in go orms wonderland :)

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Syed Alinaqvi at Nov 13, 2014 at 7:25 pm
    Thanks for excellent piece of work. To be honest before finding this I was
    thinking of re-inventing my own wheel with more or less similar features.
    To be precise I wanted to had something which is simple but powerful and
    doesn't stop you from running wild when things get crazy :)

    And this is the tool with all those attributes with additional viola for
    auto migrations.

    Thanks again for all of the hard-work and sharing with community.

    //Ali


    On Monday, October 28, 2013 10:31:25 AM UTC+8, Jinzhu wrote:


    Features Supported:

    - CURD
    - Chainable API (somehow, cooler than ActiveRecord)
    - Before/After Create/Save/Update/Delete Callbacks
    - Order/Select/Limit/Offset Support
    - Automatically CreatedAt, UpdatedAt
    - Create table from struct
    - Prevent SQL Injection
    - Goroutines friendly
    - Database Pool

    The project aims for developers friendly*, *so I think you will love it!

    Check it out, https://github.com/jinzhu/gorm
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 28, '13 at 2:31a
activeNov 13, '14 at 7:25p
posts16
users9
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase