// Create crate export async function create(parentValue, { name, description }, { auth }) { if(auth.user && auth.user.role === params.user.roles.admin) { return await models.Crate.create({ name, description }) } else { throw new Error('Operation denied.') } }
// Create or update product export function createOrUpdate(product) { if (product.id > 0) { return update(product) } else { delete product.id return create(product) } }
async testConnection() { // eslint-disable-next-line no-underscore-dangle const conn = await this.pool._factory.create(); try { return await conn.execute('SELECT 1'); } finally { // eslint-disable-next-line no-underscore-dangle await this.pool._factory.destroy(conn); } }
// This file contains the logic of every route in Forest Admin for the collection modelExport: // - Native routes are already generated but can be extended/overriden - Learn how to extend a route here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/extend-a-route // - Smart action routes will need to be added as you create new Smart Actions - Learn how to create a Smart Action here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/actions/create-and-manage-smart-actions // Create a Export router.post('/modelExport', permissionMiddlewareCreator.create(), (request, response, next) => { // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record next(); });
test('@taskr/unflow (sourceMap:`external`)', t => { t.plan(1); create({ *foo(f) { const tmp = tmpDir('tmp-4'); yield f.source(`${dir}/*.js`).unflow({ sourceMap:'external' }).target(tmp); const str = yield f.$.read(`${tmp}/foo.js`, 'utf8'); t.true(/sourceMappingURL=foo.js.map/.test(str), 'attach an `external` sourceMap link'); yield f.clear(tmp); } }).start('foo'); });
createSubscriptions(server) { _subscriptionsTransportWs.SubscriptionServer.create({ execute: _graphql.execute, subscribe: _graphql.subscribe, onOperation: async (_message, params, webSocket) => Object.assign({}, params, await this._getGraphQLOptions(webSocket.upgradeReq)) }, { server, path: this.config.subscriptionsPath || (0, _requiredParameter.default)('You must provide a config.subscriptionsPath to createSubscriptions!') }); }
it('toJSON saved object', function(done) { create({ foo: 'bar' }, function(model) { const objJSON = model.toJSON(); ok(objJSON.foo, "expected json to contain key 'foo'"); ok(objJSON.objectId, "expected json to contain key 'objectId'"); ok(objJSON.createdAt, "expected json to contain key 'createdAt'"); ok(objJSON.updatedAt, "expected json to contain key 'updatedAt'"); done(); }); });
/** * @api {post} /api/v1/device create * @apiName create * @apiGroup Device */ async function create(req, res) { const device = await gladys.device.create(req.body); res.json(device); }
memo(function CopyIcon({ isCopied }) { return isCopied ? ( <Animation name="pulse" duration="500ms"> <CheckIcon css={{ color: colors.create }} /> </Animation> ) : ( <ClippyIcon /> ); })
function wrap(innerFn, outerFn, self, tryLocsList) { // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; var generator = Object.create(protoGenerator.prototype); var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, // .throw, and .return methods. generator._invoke = makeInvokeMethod(innerFn, self, context); return generator; }
// Create subscription export async function create(parentValue, { crateId }, { auth }) { if(auth.user && auth.user.id > 0) { return await models.Subscription.create({ crateId, userId: auth.user.id }) } else { throw new Error('Please login to subscribe to this crate.') } }
this._client.offsetsForTimes(toppars, timeout, function(err, toppars) { if (err) { if (cb) { cb(LibrdKafkaError.create(err)); } return; } if (cb) { cb(null, toppars); } });
this._client.committed(toppars, timeout, function(err, topicPartitions) { if (err) { cb(LibrdKafkaError.create(err)); return; } cb(null, topicPartitions); });
// Create or update crate export function createOrUpdate(crate) { if (crate.id > 0) { return update(crate) } else { delete crate.id return create(crate) } }