I have been starting with RethinkDB. I have gone through the documentation. I have a simple use case of returning the inserted document when a POST call is made. This is something I have done so far.
router.post('/user', jsonParser, async (req: Request, res: Response) => {
const connection = await conn;
const { name, email, employeeId } = req.body;
// Email is primary key
consumerTable.insert({
name,
email,
employeeId,
}).run(connection, (err: any, result: any) => {
if (err) {
throw err;
} else {
consumerTable.get(email).run(connection, (innerErr: any, userResult: any) => {
if(innerErr) {
throw innerErr;
} else {
res.send({
data: {
...userResult
},
responseCode: 200,
});
}
});
}
});
});
Is there any way to get the inserted object in the insert result itself. I read a lot of documentation, but didn't find anything useful.
Any help would be great. Cheers!