(index, model, options, callback)
| 227 | } |
| 228 | |
| 229 | async function FindOrCreate(index, model, options, callback) { |
| 230 | ScheduleResourceTick(global.resourceName) |
| 231 | if (!Config.ORM) return ParseError("You're trying to execute a ORM query without ORM enabled in the config.js.") |
| 232 | if (typeof index === "string") { |
| 233 | if (typeof options === "function") |
| 234 | callback = options; |
| 235 | options = model; |
| 236 | model = index; |
| 237 | index = Config.DefaultORMDB; |
| 238 | } |
| 239 | if (options == null || options.length == 0) options = {}; |
| 240 | options.raw = Config.RawData; |
| 241 | |
| 242 | try { |
| 243 | const result = await poolsORM[index].models[model].findOrCreate(await ParseOperators(options)); |
| 244 | if (typeof callback === "function") return callback(result); |
| 245 | return result; |
| 246 | } catch (e) { |
| 247 | ParseError(`Can't find or create with ORM database ${index}, ${e.message}.`); |
| 248 | if (typeof callback === "function") return callback(null); |
| 249 | return null; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | async function Create(index, model, options, callback) { |
| 254 | ScheduleResourceTick(global.resourceName) |
nothing calls this directly
no test coverage detected