‫In this video, we will start creating the Dow.
‫We will create a new interface called Node Dao, which represents the data access object for our room
‫database.
‫I will create a new package here.
‫And by the way, I love to make everything ordered and.
‫Pretty.
‫In order to understand that this is a modal modal package, it's a database view, modal repository
‫and so on.
‫So I will keep my code very clean in order to understand the concepts of Mvvm and the room database.
‫I will create a new package called database, and inside this database I will create a new Kotlin class.
‫And by the way, it's an interface.
‫As I told you, it will be a node data, click enter and here we go.
‫This is our interface, the Dao.
‫And the first thing I need to make is the A O and notation.
‫In order to tell Android Studio that this interface will act as a Dao for our database.
‫I will start with suspend function insert.
‫Note it took into the parameter a note
‫variable.
‫And we've lectured before.
‫I will import this from a package.
‫From your package.
‫Okay.
‫Don't miss to make sure that you import this the correct package.
‫And by the way, it's an insert.
‫I will and insert functionality on conflict equal to on conflict strategy.
‫Dot replace.
‫Here.
‫We've used the suspend function in order to use the coroutines and do this in the background.
‫And I have lectured before why we use the suspend functions and in later lectures we will see the coroutines
‫in deep.
‫So in the next sections we will lecture about the Coroutines.
‫Don't miss to check them till now.
‫I need from you to understand that this will be a resume and able to be resumed and post function by
‫using the suspend keyword.
‫Okay.
‫And this is why we use it while dealing with database suspend function update note.
‫Tokens.
‫Parameter.
‫Node.
‫Object at delete.
‫Annotation.
‫Suspend function.
‫Delete.
‫Node.
‫Now I will create a query.
‫Two queries, but they are not suspend function.
‫These are for suspend function.
‫They are done in the background.
‫Threat.
‫Okay.
‫The query will be function.
‫Get all nodes.
‫And we've done this before in the previous videos.
‫It will return the live data.
‫And of type list of nodes.
‫Object.
‫And this query I will put here the SQL query.
‫So select all this is the all query in SQL.
‫This is the asterisk from the database table, which is the entity.
‫And I will I name the table nodes from nodes.
‫Order by ID.
‫This.
‫Order by ID.
‫Also I have ordering them by the ID column, name and desk, which is the sending order.
‫I will create another query.
‫Which is function search note Token parameter query.
‫Of type.
‫String.
‫Here would be a live data also.
‫List of note.
‫The query would be select.
‫This is a string select
‫all.
‫From notes where I am searching for.
‫So I need to check where node title like.
‫That query that I.
‫I passed it.
‫Okay.
‫Like query or.
‫Note body.
‫Like queer.
‫Okay.
‫So guys, this function will search for the past query, which is a title for the node or a node body
‫included inside the description of the node.
‫So in this case I'm using this query select all from nodes where node title like this is the like operator
‫in SQL.
‫Like query or like query like this.
‫Okay.
‫This is how we create a search function in SQL to get the exact node matching the query or the searched
‫keyword.