This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File: Regxp.h | |
* Author: solution | |
* | |
* Created on 11. listopad 2011, 16:00 | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <pcre.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// init the repository based on gorm instance | |
repository := NewRepository(database) | |
// create qo from repository, you can do it again and again | |
qo := repository.NewQueryObject(). | |
FilterByUsername("myUsername"). // compose your q. | |
FilterByActive() | |
// and than fetch it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Repository struct { | |
database *gorm.DB | |
} | |
func NewRepository(database *gorm.DB) Repository { | |
return Repository{database: database} | |
} | |
func (r Repository) NewQueryObject() *QueryObject { | |
return NewQueryObject(r.database.Session(&gorm.Session{NewDB: true})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// always use new session | |
qo := NewQueryObject(database.Session(&gorm.Session{NewDB: true})). | |
FilterByUsername("myUsername"). | |
FilterByActive() | |
// and now retrieve the model | |
var user model.User | |
qo.GetQuery().First(&user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type QueryObject struct { | |
query *gorm.DB | |
} | |
func NewQueryObject(database *gorm.DB) *QueryObject { | |
return &QueryObject{query: database.Model(&User{})} | |
} | |
func (qo *QueryObject) FilterByUsername(username string) *QueryObject { | |
qo.query = qo.query.Where("username = ?", username) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User struct { | |
gorm.Model | |
Firstname string | |
Surname string | |
Email string | |
Phone string | |
Password string | |
Role string | |
Active bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type QueryObject interface { | |
GetQuery() *gorm.DB | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User struct { | |
gorm.Model | |
Username string | |
Firstname string | |
Surname string | |
Email string | |
Phone string | |
Password string | |
Role string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Gedmo; | |
use Doctrine\Common\Annotations\AnnotationRegistry; | |
use Doctrine\ORM\Mapping\Driver as DriverMappingORM; | |
use Doctrine\Common\Persistence\Mapping\Driver as DriverORM; | |
use Doctrine\ODM\MongoDB\Mapping\Driver as DriverMongodbODM; | |
use Doctrine\Common\Annotations\Reader; | |
use Doctrine\Common\Annotations\CachedReader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package transportServiceClient | |
import ( | |
"net/http" | |
"strconv" | |
"fmt" | |
) | |
type Client struct { | |
*client.Client |
NewerOlder