Skip to content

Instantly share code, notes, and snippets.

View onisaint's full-sized avatar
🌻
::443

Madhu Kumar D S onisaint

🌻
::443
View GitHub Profile
@onisaint
onisaint / useAppCmd.ts
Last active September 25, 2023 15:48
build command group to be used with
/**
* creates a command group and adds to `CMD+K` menu
* - make sure the command groups, and commands get **unique** keys
* - if commandGroup doesn't contains commands the group will be **removed**
* - for the command shortcuts to work you need to pass the output of this command to `useKeyMap`
* to handle the shortcuts
*
* @example
* ```ts
* {
@onisaint
onisaint / create.js
Created February 24, 2018 11:52
Async/Await with mongoose
app.get('/create/:username',function (req, res) {
User
.create({
name: req.params['username']
})
.exec(function(err, user) {
if(err || user == null) {
res.send(err);
} else {
res.send({user})
@onisaint
onisaint / delete.js
Created February 24, 2018 11:44
Async/Await with mongoose
app.get('/delete/:user', async function (req, res) {
try {
let isModified = await User.remove({name: req.params['user']});
res.send(isModified);
} catch (err) {
res.send(err);
}
})
@onisaint
onisaint / Update.js
Created February 24, 2018 11:43
Async/Await with mongoose
app.get('/update/:from/:to', async function (req, res) {
try {
let user = await User.findOne({name: req.params['from']});
user.name = req.params['to'];
let isModified = await User.update({name: req.params['from']}, user);
res.send(isModified);
} catch (err) {
res.send(err);
}
})
@onisaint
onisaint / create.js
Last active May 5, 2018 15:16
Async/Await with mongoose
app.get('/create/:username', async function (req, res) {
let create;
try {
create = await User.create({name: req.params['username']});
} catch (err) {
res.send(err);
}
res.send(create);
})