Skip to content

Commit

Permalink
Adjusted NoSelection Database API
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdaniell committed Mar 22, 2021
1 parent 92bb772 commit 7f76128
Show file tree
Hide file tree
Showing 43 changed files with 83 additions and 4,737 deletions.
847 changes: 44 additions & 803 deletions .idea/workspace.xml

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions cmd/golang/golang_api/go_content_files/api_controllers_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func CreateControllersPackage(username, projectName string) {
}

writeEntityControllerFile(username, projectName)
writeServerControllerFile(projectName)
}

func writeEntityControllerFile(username, projectName string){
Expand Down Expand Up @@ -59,6 +60,28 @@ func AddEntityController(w http.ResponseWriter, r *http.Request) {
log.Fatal(err)
}

_, err = file.WriteString(content)
if err != nil {
log.Fatal(err)
}
}

func writeServerControllerFile(projectName string){
var content = `package controllers
import "net/http"
// Handle the root / route to return feedback about the server to request like "Server Running..."
func ServerRunning(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Server Running..."))
}
`

file, err := os.Create(projectName + "/api/controllers/server.go")
if err != nil {
log.Fatal(err)
}

_, err = file.WriteString(content)
if err != nil {
log.Fatal(err)
Expand Down
25 changes: 16 additions & 9 deletions cmd/golang/golang_api/go_content_files/api_repository_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func AddEntity(name string, description string) (*firestore.WriteResult, error)
var contentMongoDB = `package entity_repository
import (
\"context\"
\"errors\"
\"github.com/${username}/${nameProject}/api/db\"
\"github.com/${username}/${nameProject}/api/models\"
\"go.mongodb.org/mongo-driver/bson\"
"context"
"errors"
"github.com/`+ username +`/`+ projectName +`/api/db"
"github.com/`+ username +`/`+ projectName +`/api/models"
"go.mongodb.org/mongo-driver/bson"
)
func AddEntity(entity models.Entity) error {
Expand All @@ -89,15 +89,15 @@ func AddEntity(entity models.Entity) error {
return err
}
filter := bson.M{\"name\": entity.Name}
filter := bson.M{"name": entity.Name}
errs := client.Collection(db.EntitiesCollection).FindOne(context.Background(), filter).Decode(&exists)
if errs == nil {
return errs
}
if (exists != models.Entity{}) {
return errors.New(\"this entity already exists\")
return errors.New("this entity already exists")
}
_, err = client.Collection(db.EntitiesCollection).InsertOne(context.Background(), entity)
Expand All @@ -114,11 +114,11 @@ func DeleteEntity(name string) error {
return err
}
filter := bson.M{\"name\": \"entityName\"}
filter := bson.M{"name": "entityName"}
errs := client.Collection(db.EntitiesCollection).FindOneAndDelete(context.Background(), filter)
if errs.Err() == nil {
return errors.New(\"do not exists\")
return errors.New("do not exists")
}
return nil
Expand All @@ -127,7 +127,14 @@ func DeleteEntity(name string) error {

var contentNoSelection = `package entity_repository
import (
"github.com/`+ username +`/`+ projectName +`/api/models"
)
// Put your database functions of specific entity here.
func AddEntity(entity models.Entity) models.Entity {
return models.Entity{}
}
`

file, err := os.Create(projectName + "/api/repository/entity_repository/entity_repository.go")
Expand Down
1 change: 0 additions & 1 deletion fire/.env

This file was deleted.

21 changes: 0 additions & 21 deletions fire/.github/workflows/deploy.yml

This file was deleted.

1 change: 0 additions & 1 deletion fire/Procfile

This file was deleted.

37 changes: 0 additions & 37 deletions fire/api/controllers/entity.go

This file was deleted.

3 changes: 0 additions & 3 deletions fire/api/db/database.go

This file was deleted.

47 changes: 0 additions & 47 deletions fire/api/middlewares/middlewares.go

This file was deleted.

8 changes: 0 additions & 8 deletions fire/api/models/Entity.go

This file was deleted.

7 changes: 0 additions & 7 deletions fire/api/models/Token.go

This file was deleted.

3 changes: 0 additions & 3 deletions fire/api/repository/entity_repository/entity_repository.go

This file was deleted.

32 changes: 0 additions & 32 deletions fire/api/responses/responses.go

This file was deleted.

13 changes: 0 additions & 13 deletions fire/api/router/router.go

This file was deleted.

21 changes: 0 additions & 21 deletions fire/api/router/routes/entity_routes.go

This file was deleted.

43 changes: 0 additions & 43 deletions fire/api/router/routes/routes.go

This file was deleted.

16 changes: 0 additions & 16 deletions fire/api/router/routes/server_routes.go

This file was deleted.

22 changes: 0 additions & 22 deletions fire/api/server.go

This file was deleted.

Loading

0 comments on commit 7f76128

Please sign in to comment.