mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-14 06:49:05 +02:00
embed queries (in progress)
This commit is contained in:
@@ -20,7 +20,6 @@ require (
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
|
@@ -2,23 +2,16 @@ github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMz
|
||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
|
||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
|
||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||
github.com/bytedance/sonic v1.12.6 h1:/isNmCUF2x3Sh8RAp/4mh4ZGkcFAX/hLrzrK3AvpRzk=
|
||||
github.com/bytedance/sonic v1.12.6/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
|
||||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E=
|
||||
github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -32,18 +25,12 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.7 h1:SKFKl7kD0RiPdbht0s7hFtjl489WcQ1VyPW8ZzUMYCA=
|
||||
github.com/gabriel-vasile/mimetype v1.4.7/go.mod h1:GDlAgAyIRT27BhFl53XNAFtfjzOkLaF35JdEG0P7LtU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY=
|
||||
github.com/getkin/kin-openapi v0.127.0/go.mod h1:OZrfXzUfGrNbsKj+xmFBx6E5c6yH3At/tAKSc2UszXM=
|
||||
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
|
||||
github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
|
||||
github.com/gin-contrib/cors v1.7.4 h1:/fC6/wk7rCRtqKqki8lLr2Xq+hnV49aXDLIuSek9g4k=
|
||||
github.com/gin-contrib/cors v1.7.4/go.mod h1:vGc/APSgLMlQfEJV5NAzkrAHb0C8DetL3K6QZuvGii0=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-contrib/zap v1.1.4 h1:xvxTybg6XBdNtcQLH3Tf0lFr4vhDkwzgLLrIGlNTqIo=
|
||||
@@ -60,8 +47,6 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o=
|
||||
github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
|
||||
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
@@ -69,8 +54,6 @@ github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
|
||||
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
|
||||
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -102,8 +85,6 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
@@ -157,8 +138,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
||||
github.com/sagikazarmark/locafero v0.8.0 h1:mXaMVw7IqxNBxfv3LdWt9MDmcWDQ1fagDH918lOdVaQ=
|
||||
github.com/sagikazarmark/locafero v0.8.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
@@ -167,8 +146,6 @@ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9yS
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/speakeasy-api/openapi-overlay v0.9.0 h1:Wrz6NO02cNlLzx1fB093lBlYxSI54VRhy1aSutx0PQg=
|
||||
github.com/speakeasy-api/openapi-overlay v0.9.0/go.mod h1:f5FloQrHA7MsxYg9djzMD5h6dxrHjVVByWKh7an8TRc=
|
||||
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
||||
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
||||
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
|
||||
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=
|
||||
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
||||
@@ -208,8 +185,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/arch v0.12.0 h1:UsYJhbzPYGsT0HbEdmYcqtCv8UNGvnaL561NnIUvaKg=
|
||||
golang.org/x/arch v0.12.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@@ -276,8 +251,6 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
|
||||
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@@ -1,8 +1,18 @@
|
||||
package api
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func (srv *server) GetPersonByGoogleId(c *gin.Context, googleId string) {}
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
)
|
||||
|
||||
func (srv *server) GetPersonByGoogleId(c *gin.Context, googleId string) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), srv.dbOpTimeout)
|
||||
defer cancel()
|
||||
session := srv.db.NewSession(ctx, neo4j.SessionConfig{})
|
||||
session.ExecuteRead()
|
||||
}
|
||||
|
||||
func (srv *server) CreatePersonByGoogleIdAndInviteCode(c *gin.Context, googleId string) {}
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"github.com/vcscsvcscs/GenerationsHeritage/apps/db-adapter/pkg/gin/healthcheck"
|
||||
@@ -8,12 +10,13 @@ import (
|
||||
)
|
||||
|
||||
type server struct {
|
||||
db neo4j.DriverWithContext
|
||||
health healthcheck.HealthCheck
|
||||
logger *zap.Logger
|
||||
db neo4j.DriverWithContext
|
||||
dbOpTimeout time.Duration
|
||||
health healthcheck.HealthCheck
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func New(logger *zap.Logger, drv neo4j.DriverWithContext, healthcheck healthcheck.HealthCheck) ServerInterface {
|
||||
func New(logger *zap.Logger, drv neo4j.DriverWithContext, healthcheck healthcheck.HealthCheck, databaseOperationTimeoutInMs time.Duration) ServerInterface {
|
||||
if logger == nil {
|
||||
panic("logger is required")
|
||||
}
|
||||
@@ -26,6 +29,10 @@ func New(logger *zap.Logger, drv neo4j.DriverWithContext, healthcheck healthchec
|
||||
panic("healthcheck is required")
|
||||
}
|
||||
|
||||
if databaseOperationTimeoutInMs == 0 {
|
||||
panic("database operation timeout is required")
|
||||
}
|
||||
|
||||
return &server{db: drv, health: healthcheck, logger: logger}
|
||||
}
|
||||
|
||||
|
@@ -36,28 +36,35 @@ func TestNewServer(t *testing.T) {
|
||||
|
||||
t.Run("should create a new server instance", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
srv := New(logger, mockDriver, mockHealth)
|
||||
srv := New(logger, mockDriver, mockHealth, 1)
|
||||
assert.NotNil(t, srv)
|
||||
})
|
||||
|
||||
t.Run("should panic if logger is nil", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Panics(t, func() {
|
||||
New(nil, mockDriver, mockHealth)
|
||||
New(nil, mockDriver, mockHealth, 1)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("should panic if driver is nil", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Panics(t, func() {
|
||||
New(logger, nil, mockHealth)
|
||||
New(logger, nil, mockHealth, 1)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("should panic if healthcheck is nil", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Panics(t, func() {
|
||||
New(logger, mockDriver, nil)
|
||||
New(logger, mockDriver, nil, 1)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("should panic if databaseOperationTimeout is 0", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Panics(t, func() {
|
||||
New(logger, mockDriver, mockHealth, 0)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ func init() {
|
||||
viper.SetDefault("MEMGRAPH_PASS", "")
|
||||
viper.SetDefault("PRODUCTION", false)
|
||||
viper.SetDefault("REQUEST_TIMEOUT", 20)
|
||||
viper.SetDefault("DB_OP_TIMEOUT", 5)
|
||||
|
||||
httpPort = viper.GetString("HTTP_PORT")
|
||||
memgraphURI = viper.GetString("MEMGRAPH_URI")
|
||||
|
60
apps/db-adapter/pkg/memgraph/queries.go
Normal file
60
apps/db-adapter/pkg/memgraph/queries.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package memgraph
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed queries/create_indexes.cypher
|
||||
var CreateIndexesCypherQuery string
|
||||
|
||||
//go:embed queries/drop_indexes.cypher
|
||||
var DropIndexesCypherQuery string
|
||||
|
||||
//go:embed queries/create_constraints.cypher
|
||||
var CreateConstraintsCypherQuery string
|
||||
|
||||
//go:embed queries/drop_constraints.cypher
|
||||
var DropConstraintsCypherQuery string
|
||||
|
||||
// Requires Person parameter.
|
||||
// Returns p as person
|
||||
//go:embed queries/create_person.cypher
|
||||
var CreatePersonCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
// Returns n as person
|
||||
//go:embed queries/get_person_by_id.cypher
|
||||
var GetPersonCypherQuery string
|
||||
|
||||
// Requires id, props parameter.
|
||||
// Returns n as person
|
||||
//go:embed queries/update_person.cypher
|
||||
var UpdatePersonCypherQuery string
|
||||
|
||||
// Requires google_id parameter.
|
||||
// Returns n as person
|
||||
//go:embed queries/get_person_by_google_id.cypher
|
||||
var GetPersonByGoogleIdCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
// Returns labels(n) AS labels, n AS person
|
||||
//go:embed queries/soft_delete_person_by_id.cypher
|
||||
var SoftDeletePersonCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
//go:embed queries/hard_delete_person_by_id.cypher
|
||||
var HardDeletePersonCypherQuery string
|
||||
|
||||
// Requires id1, id2 parameters.
|
||||
//go:embed queries/get_relationship.cypher
|
||||
var GetRelationshipCypherQuery string
|
||||
|
||||
// Requires id1, id2, Relationship parameters.
|
||||
//go:embed queries/create_directed_relationship.cypher
|
||||
var CreateDirectedRelationshipCypherQuery string
|
||||
|
||||
// Requires id1, id2, Relationship1, Relationship2 parameters.
|
||||
//go:embed queries/create_two_directed_relationships.cypher
|
||||
var CreateTwoDirectedRelationshipCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
//go:embed queries/get_family_tree_by_id.cypher
|
||||
var GetFamilyTreeByIdCypherQuery string
|
@@ -5,10 +5,3 @@ CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_first_name);
|
||||
CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_last_name);
|
||||
CREATE CONSTRAINT ON (n:Person) ASSERT n.google_id IS UNIQUE;
|
||||
CREATE CONSTRAINT ON (n:Person) ASSERT n.last_name, n.first_name, n.born, n.mothers_first_name, n.mothers_last_name IS UNIQUE;
|
||||
|
||||
CREATE INDEX ON :Person(google_id);
|
||||
CREATE INDEX ON :Person(last_name);
|
||||
CREATE INDEX ON :Person(first_name);
|
||||
CREATE INDEX ON :Person(born);
|
||||
CREATE INDEX ON :Person(mothers_first_name);
|
||||
CREATE INDEX ON :Person(mothers_last_name);
|
@@ -1,4 +1,5 @@
|
||||
MATCH (a:Person), (b:Person)
|
||||
MATCH (a:Person)
|
||||
OPTIONAL MATCH (b:Person)
|
||||
WHERE id(a) = $id1 AND id(b) = $id2
|
||||
CREATE (a)-[r:Relationship $Relationship]->(b)
|
||||
RETURN r AS relationship
|
||||
RETURN r AS relationship;
|
@@ -0,0 +1,6 @@
|
||||
CREATE INDEX ON :Person(google_id);
|
||||
CREATE INDEX ON :Person(last_name);
|
||||
CREATE INDEX ON :Person(first_name);
|
||||
CREATE INDEX ON :Person(born);
|
||||
CREATE INDEX ON :Person(mothers_first_name);
|
||||
CREATE INDEX ON :Person(mothers_last_name);
|
@@ -0,0 +1,7 @@
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.last_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.first_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.born);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_first_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_last_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT n.google_id IS UNIQUE;
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT n.last_name, n.first_name, n.born, n.mothers_first_name, n.mothers_last_name IS UNIQUE;
|
6
apps/db-adapter/pkg/memgraph/queries/drop_indexes.cypher
Normal file
6
apps/db-adapter/pkg/memgraph/queries/drop_indexes.cypher
Normal file
@@ -0,0 +1,6 @@
|
||||
DROP INDEX ON :Person(google_id);
|
||||
DROP INDEX ON :Person(last_name);
|
||||
DROP INDEX ON :Person(first_name);
|
||||
DROP INDEX ON :Person(born);
|
||||
DROP INDEX ON :Person(mothers_first_name);
|
||||
DROP INDEX ON :Person(mothers_last_name);
|
@@ -0,0 +1,4 @@
|
||||
MATCH (n:Person)-[p:Parent*1..]->(family:Person)
|
||||
WHERE id(n) = $id
|
||||
OPTIONAL MATCH (family)-[c:Child*1..]->(children:Person)
|
||||
RETURN family, p, children, c, n
|
@@ -1,6 +1,6 @@
|
||||
MATCH (n:Person)-[p:Parent*1..]->(family:Person)
|
||||
WHERE id(n) = $id
|
||||
OPTIONAL MATCH (family)-[c:Child]->(children:Person)
|
||||
OPTIONAL MATCH (family)-[c:Child*..4]->(children:Person)
|
||||
WITH family, p, children, c, n
|
||||
OPTIONAL MATCH (children)<-[p2:Parent]-(OtherParents:Person)
|
||||
WITH family, p, children, c, OtherParents, p2, n
|
||||
|
@@ -0,0 +1,4 @@
|
||||
MATCH (n:Person)-[p:Parent*1..]->(family:Person)
|
||||
WHERE id(n) = $id
|
||||
OPTIONAL MATCH (family)-[c:Child*..4]->(children:Person)
|
||||
RETURN family, p, children, c, n
|
@@ -1 +0,0 @@
|
||||
MATCH (n:Person) WHERE n.id = $id RETURN n AS people
|
Reference in New Issue
Block a user