Azure Search Delete - Is there any way to specify conditions for the delete? - azure-cognitive-search

I have documents that are "owned" by particular users. The documents have the user id in a "userId" field.
I would like to issue a Delete command for a document, but also specifying conditions, for example (pseudo code) DELETE WHERE id = #documentId AND userId = #userId.
Currently the only way I can think to do this is I first issue a search SELECT WHERE id = #documentId AND userId = #userId. If I get back a document, then I know the document is owned by the expected user so I issue the delete command DELETE WHERE id = #documentId. But that requires two trips on the wire and I would prefer some way to do it in one trip.
Is there any way to do this in one command?

Currently, deleting a document is only possible via specifying its id. You seem to be asking for the more general "delete by query" functionality - please vote for this UserVoice suggestion to help us prioritize this feature. Thanks!

Related

Join User and LoginHistory in SalesForce?

I am unable to get the user information from LoginHistory object.
I tried using this
SELECT User.FirstName FROM LoginHistory
but not it says
INVALID_FIELD:
SELECT User.FirstName FROM LoginHistory
^
ERROR at Row:1:Column:8
Didn't understand relationship 'User' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
System.debug(JSON.serializePretty(LoginHistory.UserId.getDescribe())); shows "null" as the "relationshipName". Not all relations allow going "up" this way, you can check my answer https://salesforce.stackexchange.com/a/23507/799 for some examples.
You'll need to make-do with two separate queries. There's equally no way to reverse it because the related list doesn't have name either. This won't work:
SELECT FirstName,
(SELECT Id FROM LoginHistories LIMIT 10)
FROM User
LIMIT 10
Maybe there's an idea you can upvote? Maybe you'll have more luck with Event Monitoring. Haven't used it personally but my understanding is it can track login, logout, exporting a report... Might be easier to query.

Laravel 5.2 update last created record

I am new to laravel, I have tried a bunch of recommendations but none have worked for what I need. Do to requirements for design I am splitting my registration into two tables artist and the normal user table. The problem is email verification is done through the artist table. After that process has been completed I would simply like to update the last created user in the user table from 0 to 1 in the active column.
I can not figure out how to get this to work.
return $this->users()->where('verified')->first()->verified()- >orderBy('created_at', 'desc')->first();
Then ran update didn't work
User::orderby('created_at', 'desc')->first();
Then tried update didn't work
$user = User::find(1)->verified()- >update(array(
'Verified' => '1'
));
Non of the above have worked. Any suggestions are appreciated.
Given your requirements, and the way you are doing things - you are creating a user during registration (in the users table and setting verified to 0) and then putting some of their information in an artists table until they are verified.
I would add a users_id column to your artists table and set the value of this to the id of the newly created user.
When they verify, you can find their information in your artists table using their user_id and then move it anywhere you need to.

Compare two views in salesforce

I am looking for a way to compare two views in salesforce. I want to create a visual force page that lets a user select two views associated with the Account object and show all the accounts that appear on both views.
I am struggling pretty hard here, I can't figure out how to get the results from the views, but I am hoping there is a way to get all accounts that match the filters for each view.
Here is my SOQL query:
Select Id, Name, Owner.Name FROM Account WHERE
Id IN ( SELECT AccountId FROM Opportunity WHERE RecordTypeId = :RecordType1ID AND StageName IN :StageOneList )
AND Id IN ( SELECT AccountId FROM Opportunity WHERE RecordTypeId = :RecordType2ID AND StageName IN :StageTwoList )
This is the basis of the VF page I have made so far. It is possible to filter the Account with Account Owner and a drop down list from province. The idea is, many people in the organization have already created views with the accounts filtered as they need it. Instead of including every possible account field as a filter, I would like a drop down list of the active users views associated with Account, and then they can select Opportunity 1 and Opportunity 2 and have a list of Accounts matching.
I assume you mean views as in the available views in the dropdown box on a standard tab for an object? If so I don't believe you can query the results from them directly although you can query the Account object using a SOQL statement where you provide the filter.
My suggestion would be either create a set VF page that has 2 drop downs to switch the SOQL query that is used to return the list of accounts being displayed (would mean you have a set of predetermined views and updates to them require code updates) or give more details of your use case and we may be able to provide other suggestions.
It sounds like you just need to compare the results of the filters here. My suggestion would be that you're really trying to do something that should be done with reports, not with views.
Put two enhancedList components on the page.

Salesforce SOQL Queries and Tags

I'm just getting started with the Salesforce Web Services API and I'm surprised that there isn't an obvious way to do a query for all e.g. Account objects that contain certain tags.
What would you say is the best way to find all objects that contain certain tags?
I imagine it involves a join on Account.id and AccountTag.id or something similar, but despite some real research, I'm not sure how best to solve this problem.
Thanks in advance!
Update: I guess I could do a select from AccountTag and then get the account objects based on ItemId, but the ideal would be to do a query on Account, with Tags being only one part of the criteria.
You can use the SOQL-R style queries to do this, e.g. this will fetch the account Id and account Name for all the accounts with the internet tag.
select item.id, item.name from accountTag where name='internet'
in this case the item relationship is to the account that was tagged, so you can select any field from the account object through the item relationship path.
See the SOQL-R docs for more info

Database which each user sees differently - 'multiuser'/'multiview' database?

Is there an existing implementation or even a name for a type of database which allows multiple points of view? What I mean is for instance if one user changes an article's title then the change will only be visible to that particular user and everyone else will see the original title. If several users change it to the same new title then the new title becomes the 'master view', or the 'unfiltered view' of the database, initiated either by the database or from the application.
I'm coding in C# and am familiar with SQL and starting with MongoDB but the question is about the concept and whether abstractions, implementations, or design patterns of it exist.
If your "point of views" are completely separated, you could just use a new database for each user.
From your question it seems you want to have some degree of interconnectedness. Perhaps articles created by any user should be visible to everyone? Is it only changes after creation that should be private? How about updates from the original author?
I think you just need to specify the behavior you need, and design a database that can handle that.
One solution could be to use both the (article) id and the user id as the key for your tables. That way you can completely replace content for specific users. Let's say you want to find article 123, as seen by user 456, or if that user doesn't haven't edited it, as seen by user 789, or if that user haven't edited it, just pick any version:
SELECT * FROM articles WHERE id = 123 ORDER BY user_id = 456 DESC, user_id = 789 DESC LIMIT 1

Resources