This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"golang.org/x/text/language" | |
"golang.org/x/text/message" | |
) | |
func main() { | |
p := message.NewPrinter(language.English) | |
p.Printf("%d\n", 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import FluentPostgreSQL | |
import Vapor | |
struct RemoveHashColumn: Migration { | |
typealias Database = PostgreSQLDatabase | |
static func prepare( on connection: PostgreSQLConnection ) -> Future<Void> { | |
return Database.update(Files.self, on: connection) { builder in | |
connection.raw("ALTER TABLE oldName RENAME TO newName;") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension User: Migration { | |
static func prepare(on connection: PostgreSQLConnection) -> Future<void> { | |
return Database.create(self, on: connection) { builder in | |
builder.field(for: \.id, type: .int, isIdentifier: true) | |
builder.field(for: \.email, type: .string, .notNull) | |
builder.field(for: \.lifeStory, type: .text) | |
builder.field(for: \.iq, type: .int, .default(.literal("123456"))) | |
builder.field(for: \.companyID, type: .int) | |
builder.reference(from: \.companyID, to: \Company.id) | |
builder.unique(on: \.email) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Vapor | |
import FluentPostgreSQL | |
struct AddUserPassword: Migration { | |
typealias Database = PostgreSQLDatabase | |
static func prepare( on connection: PostgreSQLConnection ) -> Future<Void> { | |
return Database.update(User.self, on: connection) { builder in | |
builder.field(for: \.password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vapor build && vapor run revert // To revert the last migration | |
vapor build && vapor run revert --all // To revert all migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var commands = CommandConfig.default() | |
commands.useFluentCommands() | |
services.register(commands) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FluentPostgreSQL | |
import Vapor | |
struct AddFieldMock: Migration { | |
typealias Database = PostgreSQLDatabase | |
static func prepare( on connection: PostgreSQLConnection ) -> Future<Void> { | |
return Database.update(Acronym.self, on: connection) { builder in | |
builder.field(for: \.someFIeld) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var commands = CommandConfig.default() | |
commands.useFluentCommands() | |
services.register(commands) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get string path from some resource | |
getClass().getResource('Some name resource').getPath() | |
// Get the resource can be as stream | |
getClass().getResource('some resource') | |
// Print where is the resource folder inside .war package | |
getClass().getResource('').getPath() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const query = 'old man || the lock artist > scalzi'; | |
const result = fuseWithOperators(query, mockData); | |
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}] |
NewerOlder