Skip to content

Instantly share code, notes, and snippets.

View tagplus5's full-sized avatar
🎯
Focusing

Andrii Yuriev tagplus5

🎯
Focusing
View GitHub Profile
@rantav
rantav / README.md
Created June 27, 2012 05:18
MongoDB increment or insert

In mongodb it's easy to make at upsert, meaning update-or-insert by calling

db.collection.update({criteria}, {updated fields}, true)

The third parameter means - insert a new document if the document doesn't exist yet. So, for example, the following will insert a new document for the user if there's no document for that user yet, and will update it if it already exists:

 db.users.update({user_id: '1234'}, {user_id: '1234', name: 'Ran'}, true)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: