From cbb3256a1280d7a250cc6d39e58fbdde02534602 Mon Sep 17 00:00:00 2001 From: Jin Young Bang Date: Wed, 6 Mar 2024 21:45:38 -0500 Subject: [PATCH] feat: add flag for isNewUser --- main.go | 5 +++-- mongodb.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 16e1eb7..864cd5e 100644 --- a/main.go +++ b/main.go @@ -13,8 +13,9 @@ import ( ) type User struct { - Name string `yaml:"name"` - Email string `yaml:"email"` + Name string `yaml:"name"` + Email string `yaml:"email"` + IsNewUser bool `json:"isNewUser" bson:"isNewUser"` } type UsersData struct { diff --git a/mongodb.go b/mongodb.go index 9276b1e..cc95972 100644 --- a/mongodb.go +++ b/mongodb.go @@ -11,6 +11,7 @@ import ( // Function to insert a user into MongoDB func insertUser(client *mongo.Client, user User) error { collection := client.Database("vault").Collection("users") + user.IsNewUser = true _, err := collection.InsertOne(context.Background(), user) if err != nil { log.Printf("Error inserting user: %v", err)