Categories
Mastering Development

Keep track of last login date with NodeJS and MongoDB

I’m working on adding a last login functionality to my Node app and can’t seem to get it to work. Here’s what I’ve got for a mongoose user schema: userSchema = new mongoose.Schema({ username: { type: String, unique: true }, password: String, email: { type: String, unique: true }, avatar: String, firstName: String, lastName: String, […]

Categories
Development

`defer` order when variable persists

I’ve seen a few questions on Go’s defer, but nothing like the implementation I’m trying to do yet. The test case The application I’m writing does a fair bit of db transactions, so I have a function func getCursor() *sql.Tx { psqlInfo := fmt.Sprintf(“host=%s port=%d user=%s “+ “password=%s dbname=%s sslmode=disable”, host, port, user, password, dbname) […]

Categories
Development

Managed object attributes are sometimes nil or the default value when retrieved by their objectID

I’m having a problem with retrieving managed objects by their objectID. Most of the time I get the expected behavior. Sometimes I will request an object by its objectID, and in return I’ll get an object who’s attributes are either nil or the default value. It seems like this usually happens when I insert a […]

Categories
Development

mongodb move a string from one array to another

I need to make a request to move a string from one array to another. How can I do that ? JSON: https://jsoneditoronline.org/?id=442f1dae0b2d4997ac69d44614e55aa6 ………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………… { “_id”:”f58482b1-ae3a-4d8a-b53b-ede80fe1e225″, “bio”:{ “firstname”:”Лена”, “lastname”:”фыв”, “middlename”:””, “company”:”вв” }, “files”:[ { “_id”:”2e4e40c7-4df6-4974-8d16-bb24cd8134d6″, “destination”:”./uploads/f58482b1-ae3a-4d8a-b53b-ede80fe1e225″, “filename”:”2e4e40c7-4df6-4974-8d16-bb24cd8134d6.mp3″, “path”:”uploads\\f58482b1-ae3a-4d8a-b53b-ede80fe1e225\\2e4e40c7-4df6-4974-8d16-bb24cd8134d6.mp3″, “folder”:”f58482b1-ae3a-4d8a-b53b-ede80fe1e225″, “info”:{ “size”:20805727, “mimetype”:”audio/mp3″, “encoding”:”7bit”, “originalname”:”Ахуевший Ленусик (Банк русский стандарт). Выпуск #5..mp3″, “fieldname”:”selectedFile” }, “userId”:”5e05da745b21e61ccc84a892″, “date”:”2019-12-27T10:19:12.213Z”, “guessId”:{ […]

Categories
Development

can’t log in after creating a new user with passport & passport-local

I am using express and I can’t seem to log in once I create a new user. I check the database. The username is registered. But nothing happens when I try to log in to the account. It keeps re-directing me to the login page. Can someone tell me where I went wrong? My user […]

Categories
Development

Scala: How to define a method that returns a instance of subclass

In the project that I am working on, there is some code that is essentially as follows: sealed trait Character { def tags: Seq[String] def life: Int // other defs } object Character { def addTag[T <: Character](character: T, tag: String): T = { val newTags = character.tags :+ tag // character.copy(tags = newTags) // […]

Categories
Development

same class name in different modules

I need to use two classes with the same name in swift 5. For this, I have created those two classes in two different modules, but I am confused on how to use both the classes in an UIViewController one of my class is Person which is in models > student module and another class […]

Categories
Development JSON

.Net Core 3 and EF Core 3 Include Problem (JsonException)

After 4 years, I started to be interested in ‘.NET’ again. I’m trying to develop an application using .NET Core 3 and EF Core. I encountered an error that I could not find a solution for. I could not do on “.Net Core 3” a structure which can be simply created with PHP eloquent. Model; […]

Categories
Development

Can’t cast Data from NSKeyedUnarchiver to Object

I archive object to data and save it to disk success by NSKeyedArchiver, but when I get data from NSKeyedUnarchiver, I can’t cast it to type Object. I try to do it in many ways, but none of them success. I hope you can help me to solve this problem.. here is my code: class […]