Lodash Cheat Sheet



  1. Lodash Cheat Sheet Download
  2. Lodash Cheat Sheets
  3. Lodash Cheat Sheet
  4. Lodash Cheat Sheet Template
Pdf

.chunk(array, size=1) source npm package. Creates an array of elements split into groups the length of size.If array can't be split evenly, the final chunk will be the remaining elements. 3.0.0 Arguments. Array (Array): The array to process. size=1 (number): The length of each chunk Returns (Array): Returns the new array of chunks. Simple cheatsheet to get you started with bash. Save file and then run with.init-js.sh If you get persmission denied, with ls -l check first four flags -rw-1. Flag is file or director, then user permission, 2. If 4th flag is -you don’t have execute permission. This are default permissions settings. To change that write chmod u+x script.sh to add to the user. Lodash in Service Portal There are a number of client-side libraries included in Service Portal. We will be going over some of them in this next series, starting with the Lodash library. The version of Lodash that is included in the Service Portal is 4.17.11. Lodash cheatsheet Pug cheatsheet Yarn cheatsheet bluebird.js cheatsheet Top cheatsheets. Elixir cheatsheet ES2015+ cheatsheet React.js cheatsheet Vimdiff cheatsheet Vim cheatsheet. Lodash (Javascript Library) Cheatsheet 1 year ago 0 Lodash is a Javascript library that provides utility methods for convenience, which are not by default provided with the vanilla javascript.

-->

APPLIES TO: SQL API

In addition to issuing queries using the SQL API in Azure Cosmos DB, the Cosmos DB server-side SDK provides a JavaScript interface for performing optimized queries in Cosmos DB Stored Procedures and Triggers. You don't have to be aware of the SQL language to use this JavaScript interface. The JavaScript query API allows you to programmatically build queries by passing predicate functions into sequence of function calls, with a syntax familiar to ECMAScript5's array built-ins and popular JavaScript libraries like Lodash. Queries are parsed by the JavaScript runtime and efficiently executed using Azure Cosmos DB indices.

Supported JavaScript functions

FunctionDescription
chain() .. .value([callback] [, options])Starts a chained call that must be terminated with value().
filter(predicateFunction [, options] [, callback])Filters the input using a predicate function that returns true/false in order to filter in/out input documents into the resulting set. This function behaves similar to a WHERE clause in SQL.
flatten([isShallow] [, options] [, callback])Combines and flattens arrays from each input item into a single array. This function behaves similar to SelectMany in LINQ.
map(transformationFunction [, options] [, callback])Applies a projection given a transformation function that maps each input item to a JavaScript object or value. This function behaves similar to a SELECT clause in SQL.
pluck([propertyName] [, options] [, callback])This function is a shortcut for a map that extracts the value of a single property from each input item.
sortBy([predicate] [, options] [, callback])Produces a new set of documents by sorting the documents in the input document stream in ascending order by using the given predicate. This function behaves similar to an ORDER BY clause in SQL.
sortByDescending([predicate] [, options] [, callback])Produces a new set of documents by sorting the documents in the input document stream in descending order using the given predicate. This function behaves similar to an ORDER BY x DESC clause in SQL.
unwind(collectionSelector, [resultSelector], [options], [callback])Performs a self-join with inner array and adds results from both sides as tuples to the result projection. For instance, joining a person document with person.pets would produce [person, pet] tuples. This is similar to SelectMany in .NET LINK.

When included inside predicate and/or selector functions, the following JavaScript constructs get automatically optimized to run directly on Azure Cosmos DB indices:

  • Simple operators: =+-*/%|^&!=!<><=>=||&&<<>>>>>!~
  • Literals, including the object literal: {}
  • var, return

The following JavaScript constructs do not get optimized for Azure Cosmos DB indices:

  • Control flow (for example, if, for, while)
  • Function calls

For more information, see the Cosmos DB Server Side JavaScript Documentation.

SQL to JavaScript cheat sheet

The following table presents various SQL queries and the corresponding JavaScript queries. As with SQL queries, properties (for example, item.id) are case-sensitive.

Note

__ (double-underscore) is an alias to getContext().getCollection() when using the JavaScript query API.

SQLJavaScript Query APIDescription
SELECT *
FROM docs
__.map(function(doc) {
return doc;
});
Results in all documents (paginated with continuation token) as is.
SELECT
docs.id,
docs.message AS msg,
docs.actions
FROM docs
__.map(function(doc) {
return {
id: doc.id,
msg: doc.message,
actions:doc.actions
};
});
Projects the id, message (aliased to msg), and action from all documents.
SELECT *
FROM docs
WHERE
docs.id='X998_Y998'
__.filter(function(doc) {
return doc.id 'X998_Y998';
});
Queries for documents with the predicate: id = 'X998_Y998'.
SELECT *
FROM docs
WHERE
ARRAY_CONTAINS(docs.Tags, 123)
__.filter(function(x) {
return x.Tags && x.Tags.indexOf(123) > -1;
});
Queries for documents that have a Tags property and Tags is an array containing the value 123.
SELECT
docs.id,
docs.message AS msg
FROM docs
WHERE
docs.id='X998_Y998'
__.chain()
.filter(function(doc) {
return doc.id 'X998_Y998';
})
.map(function(doc) {
return {
id: doc.id,
msg: doc.message
};
})
.value();
Queries for documents with a predicate, id = 'X998_Y998', and then projects the id and message (aliased to msg).
SELECT VALUE tag
FROM docs
JOIN tag IN docs.Tags
ORDER BY docs._ts
__.chain()
.filter(function(doc) {
return doc.Tags && Array.isArray(doc.Tags);
})
.sortBy(function(doc) {
return doc._ts;
})
.pluck('Tags')
.flatten()
.value()
Filters for documents that have an array property, Tags, and sorts the resulting documents by the _ts timestamp system property, and then projects + flattens the Tags array.

Next steps

Learn more concepts and how-to write and use stored procedures, triggers, and user-defined functions in Azure Cosmos DB:

2019-07-02

Bash is great general purpose tool that I don’t use very often, but when I do, I wish I have cheatsheet of most used commands.

man

Manual for any command

cd

Lodash Cheat Sheet Download

Change directory

ls

List of available folders and files

flags

  • -lMore detailed list

First character is shows us if it is directory (d) or file (-), other flags are permissions. Then we see user, group and created or modified date.

  • -aTo see hidden files and folder

. and . are special folder, they mean current directory and parent directory. So to go up one level you can write cd .

cat

For checking file content

cat

For checking file content

less

Similar like cat, but better tool for file checking. First you only see file content and not previous command, secondly you can navigate more easily (g - beginning of file, shift g - end of file), you can search text with /search_term. Btw, q is for quitting less program.

.

Open current directory.It can be useful for hidden files like .git . .git

. somefile.js - will open with default program for that extension. We can select program to open it with . somefile.js TextEdit. Can be useful for files without ext or without default one.

touch

To create a file

echo

Something like print or console.log for bash

We could use it to put text in a file echo 'Some sentence I want to save' > file.txt. If we do it multiple times, it will override previous text, so to append we use >>echo ‘New sentence’ >> file.txt`

mkdir

Make new directory

To create folder and new folder in it, add -p flag

rm

Remove folder or file

To delete folder and its content add recursive flag

If you don’t want conformation message and error warning if file doesn’t exist add -f flag

mv

Move files and folders, but it also can be used for renames

Rename while moving

Just rename

cp

Copy, as with move we could also rename while copying

To copy whole folder

find

To find files and foldersa) To find all txt files in my_folder, we would write

Lodash cheat sheet

b) For case insensitive search use -iname flag

c) To find all folders in current directory

d) We can combine b) and c) to find all folder named text

d) We could combine it with delete flag to delete what we found

e) To run some operation on found files, like run imaginary encrypt on each txt file in myimportantfolder

grep

Find search term in files, every outputed line will be one search matcha) Find version in lodash package

b) We can search multiple files

c) To colorize match, —color flag

d) To output two lines before and after found search term, we have context flag -C

Lodash Cheat Sheets

e) Use regex with -e

Lodash cheat sheet 2020

curl

Output http response

a) To include headers use -i flag

b) By default curl won’t follow redirect, if we want that we use L flag

c) To include headers -H flag

d) To change http verb -X flag

e) To output to a file -o flag

f) To parse json output we could pipe it to some program, like globally installed node package jsome

Scripting

a) To init JS project

Save file and then run with .init-js.shIf you get persmission denied, with ls -l check first four flags -rw- 1. flag is file or director, then user permission, 2. read, 3. write and 4. execute. if 4th flag is - you don’t have execute permission. This are default permissions settings.To change that write chmod u+x script.sh to add to the user execute permission. Now flags should be -rwx

If we want to execute this script from anywhere we must use $PATH variable.Type echo $PATH to see all folders where shell is looking for executables.To see from where node executable is rantype which nodeTo put our file in PATH cp init-js.sh /use/local/bin/init-jsTest it with which init-js

Variables

Variables are scoped per script.

To export my_var to be accessible outside of script Clean my mac x free download.

To unset variable

To see all bash global variables

Common global var is USER, to reference it echo $USER

Script to clone a local branch from to temp folder

Functions

Passing a var to function is like a script

We can save output

We have global and local vars

Conditionals

Lodash Cheat Sheet

E.g. Print USER if it John, else print false

We can use && and ||

Piping

To see all chrome running processes in less program

Gzip file.txt and show bytes

This is outputed in memory, so new file is not created.

To output to file

Lodash

Other

Check exit status

Pause of 5 seconds

Lodash Cheat Sheet Template

Written by Nino Majder who lives and breaths web development.Follow him on Twitter