exists

MongoDB aggregate by field exists

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a hard time believing this question hasn't been asked and answered somewhere already, but I can't find any trace of it. I have a MongoDB aggregation query that needs to group by a boolean: the existence of another field. For example let's start with this collection: > db.test.find() { "_id" : ObjectId("53fbede62827b89e4f86c12e"), "field" : ObjectId("53fbede62827b89e4f86c12d"), "name" : "Erik" } { "_id" : ObjectId("53fbee002827b89e4f86c12f"), "name" : "Erik" } { "_id" : ObjectId("53fbee092827b89e4f86c131"), "field" : ObjectId(

insert if not exists oracle

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL IF NOT EXISTS( SELECT 1 WHERE fo.primary_key='bar' ) ( INSERT INTO schema.myFoo fo ( primary_key, value1, value2 ) VALUES ('bar','baz','bat') ), IF NOT EXISTS( SELECT 1 WHERE fo.primary_key='bar1' ) ( INSERT INTO schema.myFoo fo ( primary_key, value1, value2 ) VALUES ('bar1','baz1','bat1') ) SELECT * FROM schema.myFoo; Is this at all possible

Check Whether a User Exists

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to create a script to check whether a user exists. I am using the logic below: # getent passwd test > /dev/null 2&>1 # echo $? 0 # getent passwd test1 > /dev/null 2&>1 # echo $? 2 So if the user exists, then we have success, else the user does not exist. I have put above command in the bash script as below: #!/bin/bash getent passwd $1 > /dev/ null 2 &> 1 if [ $ ? - eq 0 ]; then echo "yes the user exists" else echo "No, the user does not exist" fi Now, my script always says that the user exists no matter what: # sh passwd.sh

no default constructor exists for class x (inheritance) C++

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following three headers: IBaseStates.h class IBaseStates { public: enum STATE; virtual void Update( STATE state ) = 0; }; PlayerStates.h #pragma once #include "IBaseStates.h" #include "Player.h" class PlayerStates : public IBaseStates, public Player { public: enum STATE { FLYING, FALLING }; int textureAmount; PlayerStates(); ~PlayerStates( ); void Update( STATE state ); }; Player.h #pragma once #include "StructVertex.h" #include "SquareVertices.h" #include "WICTextureLoader.h" using namespace Microsoft::WRL; using namespace

How to create sequence if not exists

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I tried to use code from Check if sequence exists in Postgres (plpgsql) . To create sequence if it does not exists. Running this code two times causes an exception: sequence ... already exists. How to create sequence only if it does not exist? If the sequence does not exist, no message should be written and no error should occur so I cannot use the stored procedure in the other answer to this question since it writes message to log file every time if sequence exists. do $$ begin SET search_path = ''; IF not EXISTS (SELECT * FROM pg_class

MySQL: Add constraint if not exists

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my create script for my database create script looking something like this: CREATE TABLE IF NOT EXISTS `rabbits` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `main_page_id` INT UNSIGNED COMMENT 'What page is the main one', PRIMARY KEY (`id`), KEY `main_page_id` (`main_page_id`) ) ENGINE=InnoDB; CREATE TABLE IF NOT EXISTS `rabbit_pages` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `rabbit_id` INT UNSIGNED NOT NULL, `title` VARCHAR(255) NOT NULL, `content` TEXT NOT NULL, PRIMARY KEY (`id`), KEY `rabbit_id` (

Laravel validation: exists with additional column condition - custom validation rule

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there is a way of referencing another field when specifying the exists validation rule in Laravel? I want to be able to say that input a must exist in table a, input b must exist in table b AND the value for column x in table b must equal input a. Best explained by example: public $rules = array( 'game_id' => 'required|exists:games,id', 'team1_id' => 'required|exists:teams,id,game_id, ', 'team2_id' => 'required|exists:teams,id,game_id, ' ); So with my validation rules I want to be able to make sure that: game_id exists within the games

How to test if string exists in file with Bash shell?

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a file that contains directory names: my_list.txt : /tmp /var/tmp I'd like to check in Bash before I'll add a directory name if that name already exists in the file. 回答1: grep -Fxq "$FILENAME" my_list.txt The exit status is 0 (true) if the name was found, 1 (false) if not, so: if grep -Fxq "$FILENAME" my_list.txt then # code if found else # code if not found fi Here are the relevant sections of the man page for grep : grep [options] PATTERN [FILE...] -F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by new-

oracle sql: update if exists else insert [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Possible Duplicate: Oracle: how to UPSERT (update or insert into a table?) Hi, I have a table in which a record has to be modified if it already exists else a new record has to be inserted. Oracle sql doesnt accept IF EXISTS , otherwise I would have done an if - update - else - insert query. I've looked at MERGE but it only works for multiple tables. What do i do? 回答1: MERGE doesn't need "multiple tables", but it does need a query as the source. Something like this should work: MERGE INTO mytable d USING ( SELECT 1 id , 'x' name

How to check if user already exists on client-side in ASP.NET MVC 5?

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Using Visual Studio 2013.4 (Visual Studio 2013 Update 4) I have created a regular ASP.NET MVC 5 project with Individual User Accounts authentication configuration. All the users registration and log-in features has been already scaffolded for me by Visual Studio and works fine. How to implement client-side validation of the following rule on the registration page: There is no already registered user with the same Email ? 回答1: You could use RemoteAttribute to perform client side validation with a server callback. 1) Add the