Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
47d5c6ed
Commit
47d5c6ed
authored
May 27, 2021
by
Shem Gyll
Committed by
Achilleas Pipinellis
May 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add examples for find_by_sql for groups and projects
parent
e46f528a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md
...dministration/troubleshooting/gitlab_rails_cheat_sheet.md
+20
-0
No files found.
doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md
View file @
47d5c6ed
...
...
@@ -356,6 +356,16 @@ DeployKeysProject.with_write_access.find_each do |deploy_key_mapping|
end
```
### Find projects using an SQL query
Find and store an array of projects based on an SQL query:
```
ruby
# Finds projects that end with '%ject'
projects
=
Project
.
find_by_sql
(
"SELECT * FROM projects WHERE name LIKE '%ject'"
)
=>
[
#<Project id:12 root/my-first-project>>, #<Project id:13 root/my-second-project>>]
```
## Wikis
### Recreate
...
...
@@ -709,6 +719,16 @@ emails.each do |e|
end
```
### Find groups using an SQL query
Find and store an array of groups based on an SQL query:
```
ruby
# Finds groups and subgroups that end with '%oup'
Group
.
find_by_sql
(
"SELECT * FROM namespaces WHERE name LIKE '%oup'"
)
=>
[
#<Group id:3 @test-group>, #<Group id:4 @template-group/template-subgroup>]
```
## Routes
### Remove redirecting routes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment