orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift

Home Page:https://orlandos.nl/docs/mongokitten/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where are the entities stored on my computer /data/db/ ?

cergeyd opened this issue · comments

Is there an example of how to create and store an entity in a local mongodb database ?��

func save(_ todo: TodoEntity, on eventLoop: EventLoop) -> Future<TodoEntity> {
        return threadPool.runIfActive(eventLoop: eventLoop) {
            let encoder = BSONEncoder()
            let document = try encoder.encode(todo)
            let id = try self.collection.insert(document)
            var result = todo
            result.id = id as? ObjectId
            return result
        }
    }

I created an entity, but I can't find it locally

Are you using MongoKitten Mobile or are you connecting with a local MongoDB server?

Are you using MongoKitten Mobile or are you connecting with a local MongoDB server?

I am connecting with a local MongoDB server

It's stored in your MongoDB server's chosen directory. If you installed it through homebrew that'll be /usr/local/var/mongodb. As defined in your mongod.conf file

Hello @cergeyd ! Did my response help?

Hello @cergeyd ! Did my response help?

I found this directory, but it's empty.
There is a file with .BSON extension and a file mongodb.lock in the /data/db directory. It in the correct directory ?

Thanks

That looks like the correct directory. If I forget to comment for whatever reason, feel free to mention me with @Joannis so I'm notified of your response.