File tree 2 files changed +15
-8
lines changed
2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ import mongoose from "mongoose";
2
2
3
3
const UserSchema = new mongoose . Schema (
4
4
{
5
- userId : {
6
- type : Number ,
7
- unique : true
8
- } ,
9
5
walletAddress : {
10
6
type : String ,
11
7
trim : true ,
@@ -17,6 +13,11 @@ const UserSchema = new mongoose.Schema(
17
13
trim : true ,
18
14
default : ""
19
15
} ,
16
+ email : {
17
+ type : String ,
18
+ trim : true ,
19
+ default : ""
20
+ } ,
20
21
avatar : {
21
22
type : String ,
22
23
trim : true ,
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ export const checkExistedWalletAddress = async (walletAddress) => {
31
31
32
32
export const createNewUser = async ( walletAddress ) => {
33
33
try {
34
+ const isExistedWallet = await checkExistedWalletAddress ( walletAddress ) ;
35
+ if ( isExistedWallet )
36
+ return {
37
+ created : false ,
38
+ message : "wallet-address-existed" ,
39
+ error : null
40
+ } ;
34
41
const newUserInfo = {
35
42
walletAddress : walletAddress
36
43
} ;
@@ -39,7 +46,7 @@ export const createNewUser = async (walletAddress) => {
39
46
. then ( ( data ) => {
40
47
return {
41
48
created : true ,
42
- message : "create user successfully" ,
49
+ message : "create- user- successfully" ,
43
50
error : null
44
51
} ;
45
52
} )
@@ -49,13 +56,13 @@ export const createNewUser = async (walletAddress) => {
49
56
50
57
return {
51
58
created : true ,
52
- message : "create user successfully" ,
59
+ message : "create- user- successfully" ,
53
60
error : null
54
61
} ;
55
62
} catch ( error ) {
56
63
return {
57
64
created : false ,
58
- message : "create user failed" ,
65
+ message : "create- user- failed" ,
59
66
error : error
60
67
} ;
61
68
}
@@ -230,7 +237,6 @@ export const followWalletOfShark = async (walletAddress, sharkId) => {
230
237
return { message : "user-notfound" } ;
231
238
if ( ! ( await checkExistedSharkId ( sharkId ) ) )
232
239
return { message : "shark-notfound" } ;
233
- console . log ( "run" ) ;
234
240
const projection = {
235
241
sharkId : 1 ,
236
242
walletAddress : 1 ,
You can’t perform that action at this time.
0 commit comments