Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notes-app
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Abhay Menon
notes-app
Commits
1bf96a77
Commit
1bf96a77
authored
2 years ago
by
thaihoangdang
Browse files
Options
Downloads
Patches
Plain Diff
Update and Delete notes
parent
ce14bf7e
No related branches found
No related tags found
1 merge request
!17
Data layer setup
Pipeline
#87260
failed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
console/src/main/kotlin/notes/multi/console/Console.kt
+30
-6
30 additions, 6 deletions
console/src/main/kotlin/notes/multi/console/Console.kt
with
30 additions
and
6 deletions
console/src/main/kotlin/notes/multi/console/Console.kt
+
30
−
6
View file @
1bf96a77
...
...
@@ -151,27 +151,28 @@ fun main(args: Array<String>) {
// reassign instance to a new note with corresponding id
newNote
=
getNote
(
1
)
println
(
newNote
.
lastModified
)
// update note with corresponding id
updateNote
(
3
,
newNote
)
// delete note with corresponding id and update id
deleteNote
(
9
)
}
}
// insert new note
fun
addNote
(
note
:
Note
)
{
transaction
{
SchemaUtils
.
create
(
Notes
)
val
newNote
=
Notes
.
insert
{
it
[
Notes
.
title
]
=
note
.
title
it
[
Notes
.
text
]
=
note
.
text
.
toString
()
it
[
Notes
.
dateCreated
]
=
note
.
dateCreated
it
[
Notes
.
lastModified
]
=
note
.
lastModified
}
get
Notes
.
id
}
}
fun
getNote
(
id
:
Int
):
Note
{
va
r
tempNote
=
Note
()
va
l
tempNote
=
Note
()
Notes
.
select
{
Notes
.
id
eq
id
}.
forEach
{
tempNote
.
title
=
it
[
Notes
.
title
]
...
...
@@ -183,3 +184,26 @@ fun getNote(id: Int): Note {
return
tempNote
}
fun
updateNote
(
id
:
Int
,
note
:
Note
)
{
Notes
.
update
({
Notes
.
id
eq
id
})
{
it
[
Notes
.
title
]
=
note
.
title
it
[
Notes
.
text
]
=
note
.
text
.
toString
()
it
[
Notes
.
dateCreated
]
=
note
.
dateCreated
it
[
Notes
.
lastModified
]
=
note
.
lastModified
}
}
fun
deleteNote
(
id
:
Int
)
{
Notes
.
deleteWhere
{
Notes
.
id
eq
id
}
updateNoteId
()
}
fun
updateNoteId
()
{
var
id
=
1
Notes
.
slice
(
Notes
.
id
).
selectAll
().
forEach
()
{
Notes
.
update
({
Notes
.
id
eq
it
[
Notes
.
id
]})
{
it
[
Notes
.
id
]
=
id
}
id
+=
1
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment