-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuserQueries.js
58 lines (55 loc) · 1003 Bytes
/
userQueries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
export const getUserQuery = userId => `*[_type=="user" && _id=="${userId}"]{
_id,
userName,
avatar
}`;
export const getCurrentUserQuery = email =>
`*[_type=="user" && email=="${email}"]`;
export const getUserCreatedPinsQuery = userId => {
const query = `*[_type=="pin" && userId == '${userId}']| order(_createdAt desc){
image{
asset->{
url
}
},
_id,
destination,
postedBy->{
_id,
userName,
avatar
},
save[]{
postedBy->{
_id,
userName,
avatar
},
},
}`;
return query;
};
export const getUserSavedPinsQuery = userId => {
const query = `*[_type == 'pin' && '${userId}' in save[].userId ] | order(_createdAt desc) {
image{
asset->{
url
}
},
_id,
destination,
postedBy->{
_id,
userName,
avatar
},
save[]{
postedBy->{
_id,
userName,
avatar
},
},
}`;
return query;
};