@enjoys/context-engine 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/data/commands/adb.json +322 -0
  2. package/data/commands/alembic.json +301 -0
  3. package/data/commands/artisan.json +277 -0
  4. package/data/commands/atlas.json +426 -0
  5. package/data/commands/auth0.json +648 -0
  6. package/data/commands/bat.json +84 -0
  7. package/data/commands/btop.json +59 -0
  8. package/data/commands/bundle.json +321 -0
  9. package/data/commands/composer.json +507 -0
  10. package/data/commands/dart.json +216 -0
  11. package/data/commands/dbmate.json +257 -0
  12. package/data/commands/docker-compose.json +384 -0
  13. package/data/commands/drizzle-kit.json +217 -0
  14. package/data/commands/expo.json +65 -0
  15. package/data/commands/fastlane.json +243 -0
  16. package/data/commands/fd.json +86 -0
  17. package/data/commands/flutter.json +298 -0
  18. package/data/commands/flyway.json +261 -0
  19. package/data/commands/fzf.json +103 -0
  20. package/data/commands/gem.json +267 -0
  21. package/data/commands/htop.json +56 -0
  22. package/data/commands/jq.json +100 -0
  23. package/data/commands/k9s.json +62 -0
  24. package/data/commands/linux.json +3007 -0
  25. package/data/commands/liquibase.json +399 -0
  26. package/data/commands/manifest.json +619 -0
  27. package/data/commands/minikube.json +60 -0
  28. package/data/commands/ng.json +64 -0
  29. package/data/commands/nuxt.json +60 -0
  30. package/data/commands/nvim.json +91 -0
  31. package/data/commands/php.json +157 -0
  32. package/data/commands/pm2.json +259 -0
  33. package/data/commands/pod.json +175 -0
  34. package/data/commands/prisma.json +257 -0
  35. package/data/commands/rails.json +372 -0
  36. package/data/commands/rake.json +360 -0
  37. package/data/commands/react-native.json +57 -0
  38. package/data/commands/rg.json +103 -0
  39. package/data/commands/rspec.json +257 -0
  40. package/data/commands/ruby.json +108 -0
  41. package/data/commands/screen.json +101 -0
  42. package/data/commands/sequelize.json +342 -0
  43. package/data/commands/snyk.json +442 -0
  44. package/data/commands/sonar-scanner.json +219 -0
  45. package/data/commands/stripe.json +314 -0
  46. package/data/commands/symfony.json +449 -0
  47. package/data/commands/tmux.json +197 -0
  48. package/data/commands/top.json +61 -0
  49. package/data/commands/trivy.json +367 -0
  50. package/data/commands/twilio.json +382 -0
  51. package/data/commands/typeorm.json +262 -0
  52. package/data/commands/vim.json +85 -0
  53. package/data/commands/vue.json +60 -0
  54. package/data/commands/wp.json +857 -0
  55. package/data/commands/xcodebuild.json +141 -0
  56. package/data/commands/yq.json +57 -0
  57. package/data/completion/bash.json +1184 -0
  58. package/data/completion/c.json +1067 -0
  59. package/data/completion/cpp.json +824 -0
  60. package/data/completion/csharp.json +860 -0
  61. package/data/completion/dockerfile.json +536 -0
  62. package/data/completion/go.json +1346 -0
  63. package/data/completion/html.json +806 -0
  64. package/data/completion/java.json +1112 -0
  65. package/data/completion/javascript.json +914 -0
  66. package/data/completion/lua.json +968 -0
  67. package/data/completion/php.json +1535 -0
  68. package/data/completion/python.json +1427 -0
  69. package/data/completion/ruby.json +1531 -0
  70. package/data/completion/rust.json +698 -0
  71. package/data/completion/sql.json +887 -0
  72. package/data/completion/toml.json +428 -0
  73. package/data/completion/typescript.json +338 -0
  74. package/data/completion/yaml.json +563 -0
  75. package/data/defination/bash.json +565 -0
  76. package/data/defination/c.json +865 -0
  77. package/data/defination/cpp.json +348 -0
  78. package/data/defination/csharp.json +144 -0
  79. package/data/defination/dockerfile.json +113 -0
  80. package/data/defination/go.json +561 -0
  81. package/data/defination/html.json +559 -0
  82. package/data/defination/java.json +184 -0
  83. package/data/defination/javascript.json +265 -0
  84. package/data/defination/lua.json +181 -0
  85. package/data/defination/php.json +726 -0
  86. package/data/defination/python.json +717 -0
  87. package/data/defination/ruby.json +670 -0
  88. package/data/defination/rust.json +207 -0
  89. package/data/defination/sql.json +473 -0
  90. package/data/defination/toml.json +251 -0
  91. package/data/defination/typescript.json +29 -0
  92. package/data/defination/yaml.json +197 -0
  93. package/data/hover/bash.json +245 -0
  94. package/data/hover/c.json +265 -0
  95. package/data/hover/cpp.json +210 -0
  96. package/data/hover/csharp.json +290 -0
  97. package/data/hover/dockerfile.json +145 -0
  98. package/data/hover/go.json +580 -0
  99. package/data/hover/html.json +250 -0
  100. package/data/hover/java.json +395 -0
  101. package/data/hover/javascript.json +330 -0
  102. package/data/hover/lua.json +265 -0
  103. package/data/hover/php.json +300 -0
  104. package/data/hover/python.json +380 -0
  105. package/data/hover/ruby.json +265 -0
  106. package/data/hover/rust.json +275 -0
  107. package/data/hover/sql.json +230 -0
  108. package/data/hover/toml.json +145 -0
  109. package/data/hover/typescript.json +120 -0
  110. package/data/hover/yaml.json +165 -0
  111. package/data/manifest.json +242 -0
  112. package/package.json +1 -1
@@ -0,0 +1,275 @@
1
+ {
2
+ "language": "rust",
3
+ "hovers": {
4
+ "println": {
5
+ "contents": [
6
+ { "value": "```rust\nmacro_rules! println\n```\nPrints to the standard output, with a newline. Uses the `format!` syntax. Panics if writing to `io::stdout()` fails." }
7
+ ]
8
+ },
9
+ "eprintln": {
10
+ "contents": [
11
+ { "value": "```rust\nmacro_rules! eprintln\n```\nPrints to the standard error, with a newline. Uses the `format!` syntax. Panics if writing to `io::stderr()` fails." }
12
+ ]
13
+ },
14
+ "format": {
15
+ "contents": [
16
+ { "value": "```rust\nmacro_rules! format\n```\nCreates a `String` using interpolation of runtime expressions. The first argument is a format string, using the same syntax as `println!`." }
17
+ ]
18
+ },
19
+ "vec": {
20
+ "contents": [
21
+ { "value": "```rust\nmacro_rules! vec\n```\nCreates a `Vec` containing the arguments. Supports two forms: `vec![a, b, c]` creates a vector with those elements, and `vec![val; n]` creates a vector of `n` copies of `val`." }
22
+ ]
23
+ },
24
+ "panic": {
25
+ "contents": [
26
+ { "value": "```rust\nmacro_rules! panic\n```\nPanics the current thread. Can be called with a formatting string and arguments or with a payload of any type that implements `Any + Send`." }
27
+ ]
28
+ },
29
+ "assert": {
30
+ "contents": [
31
+ { "value": "```rust\nmacro_rules! assert\n```\nAsserts that a boolean expression is true at runtime. If the expression is false, `panic!` is called with an optional custom message." }
32
+ ]
33
+ },
34
+ "assert_eq": {
35
+ "contents": [
36
+ { "value": "```rust\nmacro_rules! assert_eq\n```\nAsserts that two expressions are equal to each other (using `PartialEq`). On failure, prints the values of both expressions." }
37
+ ]
38
+ },
39
+ "assert_ne": {
40
+ "contents": [
41
+ { "value": "```rust\nmacro_rules! assert_ne\n```\nAsserts that two expressions are not equal to each other (using `PartialEq`). On failure, prints the values of both expressions." }
42
+ ]
43
+ },
44
+ "todo": {
45
+ "contents": [
46
+ { "value": "```rust\nmacro_rules! todo\n```\nIndicates unfinished code. Panics with \"not yet implemented\" message. Useful as a placeholder during development." }
47
+ ]
48
+ },
49
+ "unimplemented": {
50
+ "contents": [
51
+ { "value": "```rust\nmacro_rules! unimplemented\n```\nIndicates unimplemented code by panicking with \"not implemented\". Use `todo!` for code you intend to write later." }
52
+ ]
53
+ },
54
+ "dbg": {
55
+ "contents": [
56
+ { "value": "```rust\nmacro_rules! dbg\n```\nPrints and returns the value of a given expression to stderr for quick debugging. Prints the file, line number, expression, and value." }
57
+ ]
58
+ },
59
+ "write": {
60
+ "contents": [
61
+ { "value": "```rust\nmacro_rules! write\n```\nWrites formatted data into a buffer. The buffer must implement `std::fmt::Write` or `std::io::Write`. Returns `fmt::Result`." }
62
+ ]
63
+ },
64
+ "writeln": {
65
+ "contents": [
66
+ { "value": "```rust\nmacro_rules! writeln\n```\nWrites formatted data with a newline into a buffer. Same as `write!` but appends `\\n`." }
67
+ ]
68
+ },
69
+ "include_str": {
70
+ "contents": [
71
+ { "value": "```rust\nmacro_rules! include_str\n```\nIncludes a UTF-8 encoded file as a string slice (`&'static str`) at compile time. The file path is relative to the current file." }
72
+ ]
73
+ },
74
+ "include_bytes": {
75
+ "contents": [
76
+ { "value": "```rust\nmacro_rules! include_bytes\n```\nIncludes a file as a byte array reference (`&'static [u8; N]`) at compile time. The file path is relative to the current file." }
77
+ ]
78
+ },
79
+ "concat": {
80
+ "contents": [
81
+ { "value": "```rust\nmacro_rules! concat\n```\nConcatenates literals into a `&'static str`. The arguments must be literals (string, numeric, char, or boolean)." }
82
+ ]
83
+ },
84
+ "cfg": {
85
+ "contents": [
86
+ { "value": "```rust\nmacro_rules! cfg\n```\nEvaluates configuration flags at compile time. Returns `true` if the configuration predicate evaluates to true." }
87
+ ]
88
+ },
89
+ "env": {
90
+ "contents": [
91
+ { "value": "```rust\nmacro_rules! env\n```\nInspects an environment variable at compile time. Produces a compile error if the variable is not set. Returns `&'static str`." }
92
+ ]
93
+ },
94
+ "matches": {
95
+ "contents": [
96
+ { "value": "```rust\nmacro_rules! matches\n```\nReturns a `bool` indicating whether an expression matches any of the given patterns. Equivalent to a `match` with `true`/`false` arms." }
97
+ ]
98
+ },
99
+ "compile_error": {
100
+ "contents": [
101
+ { "value": "```rust\nmacro_rules! compile_error\n```\nCauses compilation to fail with the given error message when encountered. Useful in `cfg` blocks and procedural macros." }
102
+ ]
103
+ },
104
+ "String": {
105
+ "contents": [
106
+ { "value": "```rust\npub struct String\n```\nA UTF-8–encoded, growable string. It is the most common string type in Rust and owns its contents. Created via `String::new()`, `String::from()`, or `.to_string()`." }
107
+ ]
108
+ },
109
+ "Vec": {
110
+ "contents": [
111
+ { "value": "```rust\npub struct Vec<T>\n```\nA contiguous growable array type, written as `Vec<T>`. Provides O(1) indexed access, amortized O(1) push, and O(n) insert/remove." }
112
+ ]
113
+ },
114
+ "HashMap": {
115
+ "contents": [
116
+ { "value": "```rust\npub struct HashMap<K, V, S = RandomState>\n```\nA hash map implemented with quadratic probing and SIMD lookup. Requires keys to implement `Eq` and `Hash`." }
117
+ ]
118
+ },
119
+ "HashSet": {
120
+ "contents": [
121
+ { "value": "```rust\npub struct HashSet<T, S = RandomState>\n```\nA hash set implemented as a `HashMap` where the value is `()`. Provides fast membership testing." }
122
+ ]
123
+ },
124
+ "BTreeMap": {
125
+ "contents": [
126
+ { "value": "```rust\npub struct BTreeMap<K, V>\n```\nAn ordered map based on a B-Tree. Keys must implement `Ord`. Provides O(log n) lookup, insertion, and removal." }
127
+ ]
128
+ },
129
+ "Option": {
130
+ "contents": [
131
+ { "value": "```rust\npub enum Option<T> {\n None,\n Some(T),\n}\n```\nRepresents an optional value: every `Option` is either `Some` and contains a value, or `None`. Used extensively in Rust for nullable values." }
132
+ ]
133
+ },
134
+ "Result": {
135
+ "contents": [
136
+ { "value": "```rust\npub enum Result<T, E> {\n Ok(T),\n Err(E),\n}\n```\nA type for returning and propagating errors. `Ok(T)` represents success, `Err(E)` represents failure. Use the `?` operator to propagate errors." }
137
+ ]
138
+ },
139
+ "Box": {
140
+ "contents": [
141
+ { "value": "```rust\npub struct Box<T: ?Sized>\n```\nA pointer type for heap allocation. `Box<T>` provides ownership of a heap-allocated value of type `T`. When a box goes out of scope, its destructor is called and the heap memory is freed." }
142
+ ]
143
+ },
144
+ "Rc": {
145
+ "contents": [
146
+ { "value": "```rust\npub struct Rc<T: ?Sized>\n```\nA single-threaded reference-counting pointer. `Rc` provides shared ownership of a value. Cloning produces a new pointer to the same allocation. The value is dropped when the last `Rc` is dropped." }
147
+ ]
148
+ },
149
+ "Arc": {
150
+ "contents": [
151
+ { "value": "```rust\npub struct Arc<T: ?Sized>\n```\nA thread-safe reference-counting pointer. `Arc` stands for Atomically Reference Counted. It provides shared ownership across threads. Like `Rc`, but uses atomic operations for thread safety." }
152
+ ]
153
+ },
154
+ "Mutex": {
155
+ "contents": [
156
+ { "value": "```rust\npub struct Mutex<T: ?Sized>\n```\nA mutual exclusion primitive for protecting shared data. Each mutex has a type parameter `T` which is the type being protected. The data can only be accessed through the RAII guard returned from `lock()`." }
157
+ ]
158
+ },
159
+ "Cell": {
160
+ "contents": [
161
+ { "value": "```rust\npub struct Cell<T: ?Sized>\n```\nA mutable memory location for `Copy` types. Provides interior mutability by moving values in and out of the `Cell`. Not thread-safe." }
162
+ ]
163
+ },
164
+ "RefCell": {
165
+ "contents": [
166
+ { "value": "```rust\npub struct RefCell<T: ?Sized>\n```\nA mutable memory location with dynamically checked borrow rules. Provides interior mutability with runtime borrow checking. Panics on conflicting borrows." }
167
+ ]
168
+ },
169
+ "Display": {
170
+ "contents": [
171
+ { "value": "```rust\npub trait Display {\n fn fmt(&self, f: &mut Formatter<'_>) -> Result;\n}\n```\nFormat trait for an empty format, `{}`. Implementing this trait enables the type to be printed with `println!`, `format!`, etc." }
172
+ ]
173
+ },
174
+ "Debug": {
175
+ "contents": [
176
+ { "value": "```rust\npub trait Debug {\n fn fmt(&self, f: &mut Formatter<'_>) -> Result;\n}\n```\nFormat trait for the `{:?}` formatter. Should output a useful debugging representation. Can be automatically derived with `#[derive(Debug)]`." }
177
+ ]
178
+ },
179
+ "Clone": {
180
+ "contents": [
181
+ { "value": "```rust\npub trait Clone {\n fn clone(&self) -> Self;\n fn clone_from(&mut self, source: &Self) { ... }\n}\n```\nA trait for types that can explicitly duplicate themselves. Differs from `Copy` in that `Clone` can be expensive and is explicit." }
182
+ ]
183
+ },
184
+ "Copy": {
185
+ "contents": [
186
+ { "value": "```rust\npub trait Copy: Clone { }\n```\nTypes whose values can be duplicated simply by copying bits. Types that implement `Copy` are implicitly copied on assignment. Cannot be implemented for types containing heap-allocated data." }
187
+ ]
188
+ },
189
+ "Default": {
190
+ "contents": [
191
+ { "value": "```rust\npub trait Default {\n fn default() -> Self;\n}\n```\nA trait for giving a type a useful default value. Can be derived for structs where all fields implement `Default`." }
192
+ ]
193
+ },
194
+ "PartialEq": {
195
+ "contents": [
196
+ { "value": "```rust\npub trait PartialEq<Rhs: ?Sized = Self> {\n fn eq(&self, other: &Rhs) -> bool;\n fn ne(&self, other: &Rhs) -> bool { ... }\n}\n```\nTrait for equality comparisons which are partial equivalence relations. Allows `==` and `!=` operators." }
197
+ ]
198
+ },
199
+ "Eq": {
200
+ "contents": [
201
+ { "value": "```rust\npub trait Eq: PartialEq<Self> { }\n```\nTrait for equality comparisons which are equivalence relations. This is a marker trait that adds the guarantee of reflexivity to `PartialEq`." }
202
+ ]
203
+ },
204
+ "PartialOrd": {
205
+ "contents": [
206
+ { "value": "```rust\npub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {\n fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;\n}\n```\nTrait for values that can be compared for a sort-order. Enables `<`, `>`, `<=`, `>=` operators." }
207
+ ]
208
+ },
209
+ "Ord": {
210
+ "contents": [
211
+ { "value": "```rust\npub trait Ord: Eq + PartialOrd<Self> {\n fn cmp(&self, other: &Self) -> Ordering;\n}\n```\nTrait for types that form a total order. All values can be compared and the comparison is consistent." }
212
+ ]
213
+ },
214
+ "Hash": {
215
+ "contents": [
216
+ { "value": "```rust\npub trait Hash {\n fn hash<H: Hasher>(&self, state: &mut H);\n}\n```\nA hashable type. Types implementing `Hash` can be used as `HashMap` keys or `HashSet` elements." }
217
+ ]
218
+ },
219
+ "Iterator": {
220
+ "contents": [
221
+ { "value": "```rust\npub trait Iterator {\n type Item;\n fn next(&mut self) -> Option<Self::Item>;\n}\n```\nA trait for dealing with iterators. Only the `next` method is required; all other methods have default implementations built on `next`." }
222
+ ]
223
+ },
224
+ "From": {
225
+ "contents": [
226
+ { "value": "```rust\npub trait From<T> {\n fn from(value: T) -> Self;\n}\n```\nUsed for value-to-value conversions. Implementing `From<T> for U` automatically provides `Into<U> for T`." }
227
+ ]
228
+ },
229
+ "Into": {
230
+ "contents": [
231
+ { "value": "```rust\npub trait Into<T> {\n fn into(self) -> T;\n}\n```\nA conversion trait. Usually you implement `From` instead, which gives `Into` for free via blanket impl." }
232
+ ]
233
+ },
234
+ "AsRef": {
235
+ "contents": [
236
+ { "value": "```rust\npub trait AsRef<T: ?Sized> {\n fn as_ref(&self) -> &T;\n}\n```\nCheap reference-to-reference conversions. Used to make APIs accept multiple reference types." }
237
+ ]
238
+ },
239
+ "Deref": {
240
+ "contents": [
241
+ { "value": "```rust\npub trait Deref {\n type Target: ?Sized;\n fn deref(&self) -> &Self::Target;\n}\n```\nUsed for immutable dereferencing operations. Allows smart pointers to behave like references. Enables deref coercion." }
242
+ ]
243
+ },
244
+ "Drop": {
245
+ "contents": [
246
+ { "value": "```rust\npub trait Drop {\n fn drop(&mut self);\n}\n```\nCustom code within the destructor. Called when a value goes out of scope. Used for resource cleanup like closing files or freeing memory." }
247
+ ]
248
+ },
249
+ "Send": {
250
+ "contents": [
251
+ { "value": "```rust\npub unsafe auto trait Send { }\n```\nTypes that can be transferred across thread boundaries. Most types are `Send`. Notable exceptions: `Rc<T>`, raw pointers." }
252
+ ]
253
+ },
254
+ "Sync": {
255
+ "contents": [
256
+ { "value": "```rust\npub unsafe auto trait Sync { }\n```\nTypes for which it is safe to share references between threads. A type `T` is `Sync` if `&T` is `Send`. Notable exceptions: `Cell<T>`, `RefCell<T>`." }
257
+ ]
258
+ },
259
+ "Fn": {
260
+ "contents": [
261
+ { "value": "```rust\npub trait Fn<Args>: FnMut<Args> {\n extern \"rust-call\" fn call(&self, args: Args) -> Self::Output;\n}\n```\nA version of the call operator that takes an immutable receiver. Closures that only capture by immutable reference implement `Fn`." }
262
+ ]
263
+ },
264
+ "FnMut": {
265
+ "contents": [
266
+ { "value": "```rust\npub trait FnMut<Args>: FnOnce<Args> {\n extern \"rust-call\" fn call_mut(&mut self, args: Args) -> Self::Output;\n}\n```\nA version of the call operator that takes a mutable receiver. Closures that capture by mutable reference implement `FnMut`." }
267
+ ]
268
+ },
269
+ "FnOnce": {
270
+ "contents": [
271
+ { "value": "```rust\npub trait FnOnce<Args> {\n type Output;\n extern \"rust-call\" fn call_once(self, args: Args) -> Self::Output;\n}\n```\nA version of the call operator that takes a by-value receiver. All closures implement `FnOnce`; if they move captured values, they only implement `FnOnce`." }
272
+ ]
273
+ }
274
+ }
275
+ }
@@ -0,0 +1,230 @@
1
+ {
2
+ "language": "sql",
3
+ "hovers": {
4
+ "SELECT": {
5
+ "contents": [
6
+ { "value": "```sql\nSELECT [DISTINCT] column1, column2, ...\nFROM table_name\n[WHERE condition]\n[GROUP BY column]\n[HAVING condition]\n[ORDER BY column [ASC|DESC]]\n[LIMIT n [OFFSET m]]\n```\nRetrieves rows from one or more tables. The most fundamental SQL statement for querying data." }
7
+ ]
8
+ },
9
+ "INSERT": {
10
+ "contents": [
11
+ { "value": "```sql\nINSERT INTO table_name (column1, column2, ...)\nVALUES (value1, value2, ...)\n```\nInserts one or more new rows into a table. Use multiple value lists for bulk inserts, or `INSERT INTO ... SELECT` to insert from a query." }
12
+ ]
13
+ },
14
+ "UPDATE": {
15
+ "contents": [
16
+ { "value": "```sql\nUPDATE table_name\nSET column1 = value1, column2 = value2, ...\n[WHERE condition]\n```\nModifies existing rows in a table. **Always use a WHERE clause** to avoid updating all rows unintentionally." }
17
+ ]
18
+ },
19
+ "DELETE": {
20
+ "contents": [
21
+ { "value": "```sql\nDELETE FROM table_name\n[WHERE condition]\n```\nRemoves rows from a table matching the WHERE condition. Without WHERE, **all rows are deleted**. Use TRUNCATE for faster bulk deletion." }
22
+ ]
23
+ },
24
+ "CREATE TABLE": {
25
+ "contents": [
26
+ { "value": "```sql\nCREATE TABLE [IF NOT EXISTS] table_name (\n column1 data_type [constraints],\n column2 data_type [constraints],\n ...\n [TABLE constraints]\n)\n```\nCreates a new table with specified columns, data types, and constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT)." }
27
+ ]
28
+ },
29
+ "ALTER TABLE": {
30
+ "contents": [
31
+ { "value": "```sql\nALTER TABLE table_name\n ADD [COLUMN] column_name data_type\n | DROP [COLUMN] column_name\n | MODIFY [COLUMN] column_name new_data_type\n | RENAME TO new_table_name\n | ADD CONSTRAINT constraint_name ...\n```\nModifies the structure of an existing table — add, remove, or change columns and constraints." }
32
+ ]
33
+ },
34
+ "DROP TABLE": {
35
+ "contents": [
36
+ { "value": "```sql\nDROP TABLE [IF EXISTS] table_name [CASCADE]\n```\nPermanently removes a table and all its data. **This action cannot be undone.** Use IF EXISTS to avoid errors. CASCADE drops dependent objects." }
37
+ ]
38
+ },
39
+ "WHERE": {
40
+ "contents": [
41
+ { "value": "```sql\nWHERE condition\n [AND|OR condition ...]\n```\nFilters rows based on conditions. Supports comparison (`=`, `!=`, `<`, `>`, `<=`, `>=`), logical (`AND`, `OR`, `NOT`), pattern (`LIKE`, `IN`, `BETWEEN`), and NULL checks (`IS NULL`, `IS NOT NULL`)." }
42
+ ]
43
+ },
44
+ "JOIN": {
45
+ "contents": [
46
+ { "value": "```sql\n-- INNER JOIN: matching rows from both tables\nSELECT ... FROM t1 INNER JOIN t2 ON t1.col = t2.col\n\n-- LEFT JOIN: all from left + matching from right\nSELECT ... FROM t1 LEFT JOIN t2 ON t1.col = t2.col\n\n-- RIGHT JOIN: all from right + matching from left\nSELECT ... FROM t1 RIGHT JOIN t2 ON t1.col = t2.col\n\n-- FULL OUTER JOIN: all from both tables\nSELECT ... FROM t1 FULL OUTER JOIN t2 ON t1.col = t2.col\n\n-- CROSS JOIN: Cartesian product\nSELECT ... FROM t1 CROSS JOIN t2\n```\nCombines rows from two or more tables based on related columns." }
47
+ ]
48
+ },
49
+ "INNER JOIN": {
50
+ "contents": [
51
+ { "value": "```sql\nSELECT columns\nFROM table1\nINNER JOIN table2 ON table1.col = table2.col\n```\nReturns only the rows that have matching values in both tables." }
52
+ ]
53
+ },
54
+ "LEFT JOIN": {
55
+ "contents": [
56
+ { "value": "```sql\nSELECT columns\nFROM table1\nLEFT JOIN table2 ON table1.col = table2.col\n```\nReturns all rows from the left table and matching rows from the right table. Non-matching right-side columns are NULL." }
57
+ ]
58
+ },
59
+ "RIGHT JOIN": {
60
+ "contents": [
61
+ { "value": "```sql\nSELECT columns\nFROM table1\nRIGHT JOIN table2 ON table1.col = table2.col\n```\nReturns all rows from the right table and matching rows from the left table. Non-matching left-side columns are NULL." }
62
+ ]
63
+ },
64
+ "FULL OUTER JOIN": {
65
+ "contents": [
66
+ { "value": "```sql\nSELECT columns\nFROM table1\nFULL OUTER JOIN table2 ON table1.col = table2.col\n```\nReturns all rows from both tables with NULLs where there is no match. Not supported in MySQL (use UNION of LEFT and RIGHT JOIN)." }
67
+ ]
68
+ },
69
+ "GROUP BY": {
70
+ "contents": [
71
+ { "value": "```sql\nSELECT column, aggregate_function(column)\nFROM table\n[WHERE condition]\nGROUP BY column1, column2, ...\n[HAVING aggregate_condition]\n```\nGroups rows sharing common values into summary rows. Every non-aggregated column in SELECT must appear in GROUP BY." }
72
+ ]
73
+ },
74
+ "HAVING": {
75
+ "contents": [
76
+ { "value": "```sql\nSELECT column, COUNT(*)\nFROM table\nGROUP BY column\nHAVING COUNT(*) > 5\n```\nFilters grouped results based on aggregate conditions. Use HAVING instead of WHERE when filtering on aggregated values." }
77
+ ]
78
+ },
79
+ "ORDER BY": {
80
+ "contents": [
81
+ { "value": "```sql\nORDER BY column1 [ASC|DESC], column2 [ASC|DESC], ...\n```\nSorts the result set. ASC (ascending) is the default. Multiple columns create a secondary sort. NULL handling varies by database (NULLS FIRST/LAST in PostgreSQL)." }
82
+ ]
83
+ },
84
+ "UNION": {
85
+ "contents": [
86
+ { "value": "```sql\nSELECT columns FROM table1\nUNION [ALL]\nSELECT columns FROM table2\n```\nCombines results from multiple SELECT statements. UNION removes duplicates (slower). UNION ALL keeps all rows including duplicates (faster). Both queries must have the same column count and compatible types." }
87
+ ]
88
+ },
89
+ "WITH": {
90
+ "contents": [
91
+ { "value": "```sql\nWITH cte_name AS (\n SELECT columns FROM table WHERE condition\n)\nSELECT * FROM cte_name\n\n-- Recursive CTE\nWITH RECURSIVE cte AS (\n SELECT ... -- base case\n UNION ALL\n SELECT ... FROM cte WHERE ... -- recursive step\n)\nSELECT * FROM cte\n```\nCommon Table Expression (CTE): a temporary named result set. Improves readability and supports recursive queries for hierarchical data." }
92
+ ]
93
+ },
94
+ "CASE": {
95
+ "contents": [
96
+ { "value": "```sql\nCASE\n WHEN condition1 THEN result1\n WHEN condition2 THEN result2\n ELSE default_result\nEND\n\n-- Simple form\nCASE expression\n WHEN value1 THEN result1\n WHEN value2 THEN result2\n ELSE default_result\nEND\n```\nConditional expression — returns a value based on the first matching condition. Can be used in SELECT, WHERE, ORDER BY, and other clauses." }
97
+ ]
98
+ },
99
+ "EXISTS": {
100
+ "contents": [
101
+ { "value": "```sql\nSELECT columns\nFROM table1 t1\nWHERE EXISTS (\n SELECT 1 FROM table2 t2\n WHERE t2.foreign_key = t1.id\n)\n```\nReturns TRUE if the subquery returns at least one row. Often more efficient than `IN` for correlated subqueries with large datasets." }
102
+ ]
103
+ },
104
+ "LIKE": {
105
+ "contents": [
106
+ { "value": "```sql\nWHERE column LIKE pattern\n\n-- Wildcards:\n-- % matches any sequence of characters\n-- _ matches exactly one character\n\n-- Examples:\nWHERE name LIKE 'John%' -- starts with John\nWHERE name LIKE '%son' -- ends with son\nWHERE name LIKE '%oh%' -- contains oh\nWHERE code LIKE 'A_B' -- A, any char, B\n```\nPattern matching operator for string comparisons. Use `ILIKE` (PostgreSQL) for case-insensitive matching." }
107
+ ]
108
+ },
109
+ "BETWEEN": {
110
+ "contents": [
111
+ { "value": "```sql\nWHERE column BETWEEN low_value AND high_value\n\n-- Equivalent to:\nWHERE column >= low_value AND column <= high_value\n\n-- Works with dates:\nWHERE created_at BETWEEN '2024-01-01' AND '2024-12-31'\n```\nInclusive range filter for numbers, dates, and strings." }
112
+ ]
113
+ },
114
+ "IN": {
115
+ "contents": [
116
+ { "value": "```sql\n-- With a value list\nWHERE column IN ('value1', 'value2', 'value3')\n\n-- With a subquery\nWHERE column IN (SELECT column FROM other_table)\n\n-- Negation\nWHERE column NOT IN ('value1', 'value2')\n```\nTests whether a value matches any value in a list or subquery result." }
117
+ ]
118
+ },
119
+ "LIMIT": {
120
+ "contents": [
121
+ { "value": "```sql\n-- Basic limit\nSELECT * FROM table LIMIT 10\n\n-- With offset (pagination)\nSELECT * FROM table LIMIT 10 OFFSET 20\n\n-- Standard SQL equivalent\nSELECT * FROM table\nOFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY\n```\nRestricts the number of rows returned. Combined with OFFSET for pagination." }
122
+ ]
123
+ },
124
+ "COUNT": {
125
+ "contents": [
126
+ { "value": "```sql\nCOUNT(*) -- count all rows (including NULLs)\nCOUNT(column) -- count non-NULL values\nCOUNT(DISTINCT column) -- count unique non-NULL values\n```\nAggregate function that returns the number of matching rows." }
127
+ ]
128
+ },
129
+ "SUM": {
130
+ "contents": [
131
+ { "value": "```sql\nSUM(column) -- sum of all non-NULL values\nSUM(DISTINCT column) -- sum of unique values\n```\nAggregate function that returns the total sum of a numeric column. Returns NULL if no rows match." }
132
+ ]
133
+ },
134
+ "AVG": {
135
+ "contents": [
136
+ { "value": "```sql\nAVG(column) -- average of all non-NULL values\nAVG(DISTINCT column) -- average of unique values\n```\nAggregate function that returns the mean value. NULL values are ignored in the calculation." }
137
+ ]
138
+ },
139
+ "COALESCE": {
140
+ "contents": [
141
+ { "value": "```sql\nCOALESCE(value1, value2, ..., default_value)\n\n-- Example: use nickname, fall back to first_name, then 'Unknown'\nSELECT COALESCE(nickname, first_name, 'Unknown') AS display_name\nFROM users\n```\nReturns the first non-NULL value from the argument list. Essential for handling NULL values and providing defaults." }
142
+ ]
143
+ },
144
+ "CAST": {
145
+ "contents": [
146
+ { "value": "```sql\nCAST(expression AS target_type)\n\n-- Examples:\nCAST('2024-01-15' AS DATE)\nCAST(price AS DECIMAL(10,2))\nCAST(123 AS VARCHAR(10))\n```\nConverts a value from one data type to another. Standard SQL syntax supported across all major databases." }
147
+ ]
148
+ },
149
+ "ROW_NUMBER": {
150
+ "contents": [
151
+ { "value": "```sql\nROW_NUMBER() OVER (\n [PARTITION BY partition_column]\n ORDER BY sort_column [ASC|DESC]\n)\n\n-- Example: number rows per department\nSELECT name, dept,\n ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) AS rn\nFROM employees\n```\nWindow function that assigns unique sequential integers to rows within each partition." }
152
+ ]
153
+ },
154
+ "RANK": {
155
+ "contents": [
156
+ { "value": "```sql\nRANK() OVER (\n [PARTITION BY partition_column]\n ORDER BY sort_column [ASC|DESC]\n)\n\n-- Result with ties: 1, 2, 2, 4 (gap after tie)\n```\nWindow function that assigns ranks with gaps. Tied values receive the same rank; the next rank is skipped." }
157
+ ]
158
+ },
159
+ "DENSE_RANK": {
160
+ "contents": [
161
+ { "value": "```sql\nDENSE_RANK() OVER (\n [PARTITION BY partition_column]\n ORDER BY sort_column [ASC|DESC]\n)\n\n-- Result with ties: 1, 2, 2, 3 (no gaps)\n```\nWindow function that assigns ranks without gaps. Tied values get the same rank, and the next rank follows immediately." }
162
+ ]
163
+ },
164
+ "LEAD": {
165
+ "contents": [
166
+ { "value": "```sql\nLEAD(column, offset, default) OVER (\n [PARTITION BY partition_column]\n ORDER BY sort_column\n)\n\n-- Example: compare with next row's value\nSELECT date, revenue,\n LEAD(revenue, 1) OVER (ORDER BY date) AS next_day_revenue\nFROM daily_sales\n```\nWindow function that accesses a subsequent row's column value without a self-join. Offset defaults to 1." }
167
+ ]
168
+ },
169
+ "LAG": {
170
+ "contents": [
171
+ { "value": "```sql\nLAG(column, offset, default) OVER (\n [PARTITION BY partition_column]\n ORDER BY sort_column\n)\n\n-- Example: compare with previous row's value\nSELECT date, revenue,\n LAG(revenue, 1) OVER (ORDER BY date) AS prev_day_revenue\nFROM daily_sales\n```\nWindow function that accesses a preceding row's column value. Useful for calculating differences between consecutive rows." }
172
+ ]
173
+ },
174
+ "PRIMARY KEY": {
175
+ "contents": [
176
+ { "value": "```sql\n-- Inline definition\nCREATE TABLE users (\n id INT PRIMARY KEY AUTO_INCREMENT,\n ...\n);\n\n-- Table-level (composite key)\nCREATE TABLE order_items (\n order_id INT,\n item_id INT,\n PRIMARY KEY (order_id, item_id)\n);\n```\nUniquely identifies each row in a table. Combines NOT NULL and UNIQUE. Only one primary key per table." }
177
+ ]
178
+ },
179
+ "FOREIGN KEY": {
180
+ "contents": [
181
+ { "value": "```sql\nCREATE TABLE orders (\n id INT PRIMARY KEY,\n user_id INT,\n CONSTRAINT fk_user\n FOREIGN KEY (user_id)\n REFERENCES users(id)\n ON DELETE CASCADE\n ON UPDATE CASCADE\n);\n\n-- Actions: CASCADE, SET NULL, RESTRICT, NO ACTION, SET DEFAULT\n```\nEnforces referential integrity by ensuring values in a column match values in another table's primary key." }
182
+ ]
183
+ },
184
+ "INDEX": {
185
+ "contents": [
186
+ { "value": "```sql\n-- Create index\nCREATE INDEX idx_name ON table(column);\nCREATE UNIQUE INDEX idx_email ON users(email);\nCREATE INDEX idx_composite ON table(col1, col2);\n\n-- Drop index\nDROP INDEX idx_name ON table;\n```\nIndexes speed up data retrieval at the cost of additional storage and slower writes. Essential for columns used in WHERE, JOIN, and ORDER BY." }
187
+ ]
188
+ },
189
+ "BEGIN": {
190
+ "contents": [
191
+ { "value": "```sql\nBEGIN TRANSACTION;\n -- SQL statements\n INSERT INTO ...\n UPDATE ...\nCOMMIT;\n\n-- On error:\nROLLBACK;\n\n-- With savepoints:\nBEGIN;\n SAVEPOINT sp1;\n -- statements\n ROLLBACK TO sp1;\nCOMMIT;\n```\nStarts a transaction. All subsequent operations are grouped and applied atomically with COMMIT, or undone with ROLLBACK." }
192
+ ]
193
+ },
194
+ "EXPLAIN": {
195
+ "contents": [
196
+ { "value": "```sql\nEXPLAIN SELECT * FROM users WHERE email = 'test@example.com';\n\n-- With actual execution stats (PostgreSQL)\nEXPLAIN ANALYZE SELECT ...;\n\n-- MySQL extended\nEXPLAIN FORMAT=JSON SELECT ...;\n```\nDisplays the query execution plan chosen by the database optimizer. Shows index usage, join strategies, and estimated row counts. Essential for query performance tuning." }
197
+ ]
198
+ },
199
+ "CONCAT": {
200
+ "contents": [
201
+ { "value": "```sql\nCONCAT(string1, string2, ...)\n\n-- Examples:\nSELECT CONCAT(first_name, ' ', last_name) AS full_name\nFROM users;\n\n-- PostgreSQL also supports:\nSELECT first_name || ' ' || last_name\nFROM users;\n```\nConcatenates two or more strings. Returns NULL if any argument is NULL in standard SQL." }
202
+ ]
203
+ },
204
+ "SUBSTRING": {
205
+ "contents": [
206
+ { "value": "```sql\nSUBSTRING(string, start, length)\nSUBSTRING(string FROM start FOR length)\n\n-- Examples:\nSELECT SUBSTRING('Hello World', 1, 5); -- 'Hello'\nSELECT SUBSTRING(email, 1, POSITION('@' IN email) - 1) AS username\nFROM users;\n```\nExtracts a portion of a string starting at a 1-based position for the given length." }
207
+ ]
208
+ },
209
+ "NOW": {
210
+ "contents": [
211
+ { "value": "```sql\n-- Current date and time\nSELECT NOW(); -- 2024-03-15 14:30:00\nSELECT CURRENT_TIMESTAMP; -- equivalent\nSELECT CURRENT_DATE; -- date only\nSELECT CURRENT_TIME; -- time only\n```\nReturns the current date and time. Useful for timestamps, age calculations, and filtering by date." }
212
+ ]
213
+ },
214
+ "EXTRACT": {
215
+ "contents": [
216
+ { "value": "```sql\nEXTRACT(part FROM date_expression)\n\n-- Parts: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, DOW, DOY\nSELECT EXTRACT(YEAR FROM created_at) AS year,\n EXTRACT(MONTH FROM created_at) AS month\nFROM orders;\n```\nExtracts a specific component from a date or timestamp value. Standard SQL syntax." }
217
+ ]
218
+ },
219
+ "TRUNCATE": {
220
+ "contents": [
221
+ { "value": "```sql\nTRUNCATE TABLE table_name;\n```\nRemoves all rows from a table very quickly. Unlike DELETE, it does not log individual row deletions, resets auto-increment counters, and **cannot be rolled back** in most databases." }
222
+ ]
223
+ },
224
+ "GRANT": {
225
+ "contents": [
226
+ { "value": "```sql\n-- Grant specific privileges\nGRANT SELECT, INSERT ON database.table TO 'user'@'host';\n\n-- Grant all privileges\nGRANT ALL PRIVILEGES ON database.* TO 'user'@'host';\n\n-- Allow user to grant to others\nGRANT SELECT ON table TO user WITH GRANT OPTION;\n```\nGrants access privileges on database objects to users or roles." }
227
+ ]
228
+ }
229
+ }
230
+ }