Skip to content

incker/go_test_mongo_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang test API server with mongo database

Installation

Create config

touch configs/apiserver.toml

Config file can be empty, as it has default values, but you can add custom values something like:

bind_addr = ":8080"
log_level = "debug"
mongodb_url = "mongodb://localhost:27017"
mongodb_name = "testing"

Build server

make

Run tests

make test

Fill in database from users_go.json file

  1. Download file provided in test task: users_go.json
  2. Delete some data in users_go.json file, so it will start with [ and end with ]
  3. Import file data: mongoimport --db testing --collection user --file users_go.json --type json --jsonArray --batchSize 1
  4. convert birth_date from string to date
db.user.find().forEach((el) => {
   el.birth_date = new Date(el.birth_date);
   db.user.save(el)
});
  1. Create index db.user.createIndex( { "email": 1 }, { unique: true } )

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published