i'm trying to convert a collection to a capped collection, but i'm having trouble getting the syntax right. can someone tell me how to refer to my collection? it's full name is manage.api_requests. here is what i've tried so far:
> db.runCommand( { convertToCapped:api_requests, size: 38654705664 } )
Sat Mar 26 10:29:02 ReferenceError: api_requests is not defined (shell):1
> db.runCommand( { convertToCapped:db.api_requests, size: 38654705664 } )
{
"errmsg" : "cloneCollectionAsCapped failed: { errmsg: \"exception: source collection manage.manage.api_requests does not exist\", code: 10301, ok: 0.0 }",
"ok" : 0
}
> db.runCommand( { convertToCapped:manage.api_requests, size: 38654705664 } )
Sat Mar 26 10:42:40 ReferenceError: manage is not defined (shell):1
The collection name must be quoted of course.
You are expected to pass a string to this command. If new collection is to be called "api_requests" that pass that - including the "" - otherwise, it's not a string and the shell tries to resolve it as a variable name.
Related
I am trying to create a schema using node package dynamodb/vogels but it is throwing Invalid schema content. I used the below sample schema
var Account = vogels.define('Account', {
hashKey : 'email',
// add the timestamp attributes (updatedAt, createdAt)
timestamps : true,
schema : {
email : Joi.string().email(),
name : Joi.string(),
age : Joi.number(),
roles : vogels.types.stringSet(),
settings : {
nickname : Joi.string(),
acceptedTerms : Joi.boolean().default(false)
}
}
});
error details
Uncaught Error: Invalid schema content:
node_modules/vogels/node_modules/hoek/lib/index.js:731
Debugger attached.
Waiting for the debugger to disconnect...
c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\hoek\lib\index.js:731
throw new Error(msgs.join(' ') || 'Unknown error');
^
Error: Invalid schema content:
at Object.exports.assert (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\hoek\lib\index.js:731:11)
at Object.exports.schema (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\cast.js:65:10)
at internals.Object.keys (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\object.js:269:25)
at Object.exports.schema (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\cast.js:46:33)
at internals.Object.keys (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\object.js:269:25)
at Object.exports.schema (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\cast.js:46:33)
at internals.Object.keys (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\object.js:269:25)
at c:\my-workspace\dynamoDB\node_modules\vogels\lib\schema.js:105:74
at internals.Object.internals.Any._validateWithOptions (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\any.js:460:16)
at module.exports.internals.Any.root.validate (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\index.js:102:23)
Process exited with code 1
Has anyone come across this or know how to create the schema using node page dynamodb/vogels?
on_conflict returns unknown argument
new to hasura, tried looking at multiple how to on_conflict, ran mutation from api explorer and from frontend, tried upsert_users (suggest me to change it to insert)
mutation upsert_users {
insert_users(
objects: [{
auth0_id: "iexistindb",
name: "somename"}
],
on_conflict: {
constraint: users_pkey,
update_columns: [last_seen, name]
}
) {
affected_rows
}
}
expected to update the user table if auth0 already exist
so i just encountered this now. i had the on_conflict / update_columns but hadn't given update permissions to the role, only insert
When attempting to delete an item using the following request mapping:
{
"version" : "2017-02-28",
"operation" : "DeleteItem",
"key" : {
"id": { "S" : "$ctx.args.id"},
"sortKey" : { "S" : "$ctx.args.sortKey"}
}
}
If the item exists it will process the result through the response template, however when the item does not exist the response template is never run.
Response template:
#set($ctx.result.status = "SUCCESS")
#set($ctx.result.message = "This was a success!")
$utils.toJson($ctx.result)
I am aware that when an item does not exist in Dynamo it will perform no action but I would expect that it would still process through the template.
Is there anything I am missing or is it impossible for AppSync to processed a DeleteItem request through the response mapping when the document does not exist?
This the expected execution behavior for the version of the template you are using (2017-02-28).
You can switch your request mapping template version to 2018-05-29 and your response mapping template will be executed, with the following characteristics:
If the datasource invocation result is null, the response mapping template is executed.
If the datasource invocation yields an error, it is now up to you to handle the error. The invocation error is accessible using $ctx.error.
The response mapping template evaluated result will always be placed inside the GraphQL response data block. You can also raise or append an error using $util.error() and $util.appendError() respectively.
More info https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-changelog.html#aws-appsync-resolver-mapping-template-version-2018-05-29
So for your example:
{
"version" : "2018-05-29", ## Note the new version
"operation" : "DeleteItem",
"key" : {
"id": { "S" : "$ctx.args.id"},
"sortKey" : { "S" : "$ctx.args.sortKey"}
}
}
and response template
#if ( $ctx.error )
$util.error($ctx.error.message, $ctx.error.type)
#end
#set($ctx.result.status = "SUCCESS")
#set($ctx.result.message = "This was a success!")
$utils.toJson($ctx.result)
Does Firebase allow for dynamic indexes for searches!?
I have the following structure:
PlayerInPool: {
12345: <- PoolId
DUmwewIfzAbfWZN4NjS8mhX82 : true <- UserId
LpWgezRkC6EWS0sjXEWxhFl2 : true
etc...
}
}
I put an observer as such:
ref.queryOrdered(byChild: (Auth.auth().currentUser?.uid)!).queryEqual(toValue: true).observe(.value, with: { snapshot in ...
When I run the app I get the following warning:
[Firebase/Database][I-RDB034028] Using an unspecified index.
Consider adding ".indexOn": "DUmwewIfzAbfWZN4NjS8mhX82" at
/PlayerInPool to your security rules for better performance
I am trying to do the following in the 'Rules' in Firebase
"PlayerInPool": {
".indexOn" : "auth.uid"
}
but it wont allow it stating that :
Error saving rules - Line 45: Invalid key: auth.uid. Index must be
either .value or declared on a valid path
How can I get this to work!?
Updated Comment
If I invert the structure as suggested I would get this:
PlayerInPool: {
DUmwewIfzAbfWZN4NjS8mhX82: <- UserId
12345 : true <- PoolId
98765 : true
LpWgezRkC6EWS0sjXEWxhFl2:
12345 : true
}
}
I'm not entirely sure how this changes anything!?
Based on Tom's answer to this question, I'm getting the following error when trying to query a nested field on a collection.
I'm trying to get a single user object with personalityExams.id.extId = 24232. I'd like to know the best way to query this, and how to form an index rule for it.
Here is what the user looks like in firebase
{
"users": {
"93306b91-d5ba-4e06-838c-0ab85fd58783": {
"createdOn" : 1451495976870,
"email" : "iyad.bitar#gmail.com",
"firstName" : "Iyad",
"lastModifiedOn" : 1451590413654,
"lastName" : "Bitar",
"mobile" : "34234333",
"provider" : "password",
"userType" : "JS",
"personalityExams": [
{
"extId": "24232",
"skills": ["teaching"]
}
]
}
In my javascript, I'm trying to get it like so:
(new Firebase("https://hirely-dev.firebaseio.com/users")).orderByValue("personalityExams/extId").equalTo("24232").on("value", function(snapshot) {user1 = snapshot.val();});
Error:
Uncaught Error: Query.orderByValue failed: Was called with 1 argument. Expects none.
at Error (native)
at x (http://localhost:7200/lib/firebase/firebase.js:20:1074)
at U.g.Fg (http://localhost:7200/lib/firebase/firebase.js:233:343)
at <anonymous>:2:59
at Object.InjectedScript._evaluateOn (<anonymous>:875:140)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:808:34)
at Object.InjectedScript.evaluate (<anonymous>:664:21)