- What is smallCode in brief ?
{
"groups": [
{
"ref": "Group",
"required": true,
"type": "ObjectId"
}
],
"email": {
"required": true,
"type": "String",
"unique": true
},
"password": {
"required": true,
"type": "String"
},
"username": {
"type": "String"
}
}
{
"author": {
"ref": "User",
"required": true,
"type": "ObjectId"
},
"title": {
"required": true,
"type": "String"
},
"about": {
"type": "String"
}
}
const user = createUser({
email: body.email,
password: body.pwd,
username: body.uname
});
Usecase: Add group to user
const user = findUserById(params.id);
const group = createGroup({
author: user,
about: body.about,
title: body.title,
});
const updatedUser = updateUserById(user._id, {
$push: { groups: group }
});
Usecase: Get user's groups
const userGroups = findGroupsByQuery({ author: params.id });
const user = findUserById(params.id);
const userGroups = findGroupsByQuery({ author: user._id });
const userWithItsGroups = findUserById(params.id, 'groups', {
populate: { path: "groups" },
});
![alt text](https://github.com/tutanck/Tz23/raw/main/How_it_works.jpg)
![alt text](https://github.com/tutanck/Tz23/raw/main/Tz23QRCode.png)